graph-traversal

neo4j logic gate simulation, how to?

China☆狼群 提交于 2019-12-11 03:14:39
问题 I would like to create a bunch of "and" and "or" and "not" gates in a directed graph. And then traverse from the inputs to see what they results are. I assume there is a ready made traversal that would do that but I don't see it. I don't know what the name of such a traversal would be. Certainly breadth first will not do the job. I need to get ALL the leaves, and go up toward the root. In other words A = (B & (C & Z)) I need to resolve C @ Z first. I need to put this type of thing in a graph

Find path between two nodes in graph, according to given criteria - optimization task

不羁岁月 提交于 2019-12-08 07:59:37
问题 I have the following problem. I have cyclic, undirected, weighted graph G=(V,E). I need to find the simple path (without cycles) between two given nodes according to these rules: Finding minimal weight value in edges set of each possible path Select this path, which has maximal min value among selected minimal values from found paths E.g we have graph presented below: We can try to find simple path from node 1 to node 8. There are two possible pathes, listed below: 1 -> 3 -> 5 -> 8, minimal

Random Walk on Bipartite Graph with Gremlin

时光毁灭记忆、已成空白 提交于 2019-12-06 06:46:29
问题 I would like to rank items according to a given users preference (items liked by the user) based on a random walk on a directed bipartite graph using gremlin in groovy. The graph has the following basic structure: [User1] ---'likes'---> [ItemA] <---'likes'--- [User2] ---'likes'---> [ItemB] Hereafter the query that I came up with: def runRankQuery(def userVertex) { def m = [:] def c = 0 while (c < 1000) { userVertex .out('likes') // get all liked items of current or similar user .shuffle[0] //

Random Walk on Bipartite Graph with Gremlin

£可爱£侵袭症+ 提交于 2019-12-04 13:30:35
I would like to rank items according to a given users preference (items liked by the user) based on a random walk on a directed bipartite graph using gremlin in groovy. The graph has the following basic structure: [User1] ---'likes'---> [ItemA] <---'likes'--- [User2] ---'likes'---> [ItemB] Hereafter the query that I came up with: def runRankQuery(def userVertex) { def m = [:] def c = 0 while (c < 1000) { userVertex .out('likes') // get all liked items of current or similar user .shuffle[0] // select randomly one liked item .groupCount(m) // update counts for selected item .in('likes') // get

ArangoDB: Get every node, which is in any way related to a selected node

点点圈 提交于 2019-12-04 08:26:30
I have a simple node-links graph in ArangoDB. How can I traverse from 1 preselected node and return all nodes which are related to it? For example: A→B, B→C, C→D, C→E, F→B, F→E Selecting any of them should return the same result (all of them). I am very new to ArangoDB. What you need is AQL graph traversal , available since ArangoDB 2.8. Older versions provided a set of graph-related functions, but native AQL traversal is faster, more flexible and the graph functions are no longer available starting with 3.0. AQL traversal let's you follow edges connected to a start vertex, up to a variable

How to implement a DFS with immutable data types

爱⌒轻易说出口 提交于 2019-12-03 12:54:41
I'm trying to figure out a neat way of traversing a graph Scala-style, preferably with vals and immutable data types. Given the following graph, val graph = Map(0 -> Set(1), 1 -> Set(2), 2 -> Set(0, 3, 4), 3 -> Set(), 4 -> Set(3)) I'd like the output to be the depth first traversal starting in a given node. Starting in 1 for instance, should yield for instance 1 2 3 0 4 . I can't seem to figure out a nice way of doing this without mutable collections or vars. Any help would be appreciated. Tail Recursive solution: def traverse(graph: Map[Int, Set[Int]], start: Int): List[Int] = { def

Arangodb AQL recursive graph traversal

不想你离开。 提交于 2019-12-02 00:50:30
I have a graph with three collections which items can be connected by edges. ItemA is a parent of itemB which in turn is a parent of itemC. Elements only can be connected by edges in direction "_from : child, _to : parent" Currently I can get only "linear" result with this AQL query: LET contains = (FOR v IN 1..? INBOUND 'collectionA/itemA' GRAPH 'myGraph' RETURN v) RETURN { "root": { "id": "ItemA", "contains": contains } } And result looks like this: "root": { "id": "itemA", "contains": [ { "id": "itemB" }, { "id": "itemC" } ] } But I need to get a "hierarchical" result of graph traversal

Completeness of depth-first search

情到浓时终转凉″ 提交于 2019-12-01 02:22:32
I quote from Artificial Intelligence: A Modern Approach : The properties of depth-first search depend strongly on whether the graph-search or tree-search version is used. The graph-search version, which avoids repeated states and redundant paths, is complete in finite state spaces because it will eventually expand every node. The tree-search version, on the other hand, is not complete [...]. Depth-first tree search can be modified at no extra memory cost so that it checks new states against those on the path from the root to the current node; this avoids infinite loops in finite state spaces

Breadth First enumeration in Gremlin

别来无恙 提交于 2019-12-01 01:34:38
I'm trying to get breadth first enumeration working with Gremlin, however I'm having trouble finding a way to output all the steps observed during the enumeration. I can only print out the result of the last iteration. My question would be, given a starting node like this, how can I follow all paths (without knowing the overall depth) using Gremlin and print out everything I find along the way? study=g.v('myId') I have tried the scatter approach, looping approach (although both seem to require knowledge about the actual length of the path beforehand if I understand correctly) Many thanks! You

Good graph traversal algorithm

允我心安 提交于 2019-11-30 07:27:23
问题 Abstract problem : I have a graph of about 250,000 nodes and the average connectivity is around 10. Finding a node's connections is a long process (10 seconds lets say). Saving a node to the database also takes about 10 seconds. I can check if a node is already present in the db very quickly. Allowing concurrency, but not having more than 10 long requests at a time, how would you traverse the graph to gain the highest coverage the quickest. Concrete problem : I'm trying to scrape a website