Questions tagged [graph-traversal]

Graph traversal is the problem of visiting all the nodes in a graph in a particular manner, updating and/or checking their values along the way.

Two famous graph traversal algorithms are:

See also:

371 questions
6
votes
1 answer

Handling duplicate nodes in Breadth First Search

Imagine there is a graph. The nodes are of the form GraphNode. The graph can have duplicate nodes. We have to do a BFS on the graph. We do not know the entire graph in the beginning, i.e., there is no way to index the nodes of the graph. For eg,…
6
votes
1 answer

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

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…
Loredra L
  • 1,485
  • 2
  • 16
  • 32
6
votes
1 answer

C# minmax graph search

EDIT 3: Okay, so i got my code to work, but i'm facing a huge memory consumption problem if i'm using let's say 16 nodes and a search depth above 11. an soemone check the code and tell me how can i correct that memory leak? Here's the full…
5
votes
4 answers

Returning only the vertices in the actual shortest path

I know the title is a bit messy, but I don't know how to explain it better. What I'm trying to do: Using a graph found in a text file, find and print the shortest path (minimum amount of vertices) from vertex A to vertex B. Note: using breadth-first…
bjrnt
  • 2,552
  • 3
  • 27
  • 38
5
votes
1 answer

Gremlin graph traversal that uses previous edge property value to filter later edges

In a graph traversal I only want to consider edges that have a property that is equal to the property of one of the edges visited in a previous step in the traversal. I found…
Chris Reeves
  • 59
  • 1
  • 3
5
votes
2 answers

Linking graphs of structures by pointer vs. index in array

This is question about good practice Consider situation which is typical e.g. in 3D engines, physics engines, Finite element method or classical molecular dynamics solvers: You have objects of various types ( e.g. vertexes, edges, faces, bounded…
Prokop Hapala
  • 2,424
  • 2
  • 30
  • 59
5
votes
2 answers

How do I handle recursion in a custom PyYAML constructor?

PyYAML can handle cyclic graphs in regular python objects. For example: Snippet #1. class Node: pass a = Node() b = Node() a.child = b b.child = a # We now have the cycle a->b->a serialized_object = yaml.dump(a) object =…
4
votes
1 answer

Translating from Cypher query to traversal framework for neo4j

I have this traversal: TraversalDescription td = graph.traversalDescription() .depthFirst() .relationships(RelationshipTypes.CHILD, Direction.INCOMING) .evaluator(new Evaluator() { @Override …
rabolfazl
  • 435
  • 1
  • 8
  • 24
4
votes
5 answers

How would you represent a graph (the kind associated with the travelling salesman problem) in Haskell

It's pretty easy to represent a tree in haskell: data Tree a = Node Tree a Tree | Leaf a but that's because it has no need for the concept of an imperative style "pointer" because each Node/Leaf has one, and only one parent. I guess I could…
Tom Busby
  • 1,319
  • 2
  • 12
  • 25
4
votes
2 answers

Is the Euler Tour algorithm essentially the same as Pre-order traversal?

I'm trying to learn about the Euler Tour algorithm and why it's popular for tree traversal. However, I'm failing to see the difference between a Euler Tour and a Pre-order traversal of a tree. Let's say you have the tree: A / \ B E …
Bob
  • 166
  • 3
  • 15
4
votes
3 answers

Turing complete graph query languages

Is it accurate to say that of the existing graph query languages (Cypher, Datalog, Sparql etc) Gremlin is the only one that's Turing complete? In case it matters, I'm not looking for edge cases like the Turing completeness proof of Magic: the…
rwallace
  • 31,405
  • 40
  • 123
  • 242
4
votes
3 answers

How to determine the path between 2 nodes, given the shortest distance matrix between the nodes?

How to determine the shortest path between 2 nodes, given the shortest distance matrix between the nodes of a graph? For example, I have 4 nodes and the shortest distance matrix(m). 0 4 5 8 4 0 6 3 5 6 0 2 8 3 2 0 m(i,j) is the distance of the path…
aries
  • 849
  • 3
  • 11
  • 24
4
votes
1 answer

BGL - BFS/DFS visitor, accessing vertex colours

In BGL, I can't quite figure out how to access the inherent colouring of the vertexes (white for untouched, grey for visited, black for finished) in a graph as they are visited during a bfs/dfs search. Could somebody illustrate how to access a…
User1291
  • 7,664
  • 8
  • 51
  • 108
4
votes
1 answer

Doing a DFS on a neo4j graph

I have a database with the following structure. The property node is of the type create (A:Property {value:"abc"}) How to do a dfs so that it will be able to print all the values in the graph.In the order A->B->E->F->C->G->H->D->I->J The…
lost Coder
  • 577
  • 2
  • 8
  • 34
4
votes
1 answer

GremlinPipeLine java API chain traversal in Titan graph use cases

I have use case where in I have to traverse a chain of vertices starting from a particular vertex. Its a linear chain (like a train) with only one vertex connected to the previous.While traversing I have to emit certain vertices based on some…
user3244615
  • 330
  • 1
  • 15
1
2
3
24 25