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
-1
votes
3 answers

How to resolve OutOfMemoryError: Java heap space when traversing to find all possible paths with huge graph?

I am implementing a graph traversal to look for all possible paths, and it works fine with a small sample graph. But when I bring it to a larger graph (having 1000 vertex), the program crashes with OutOfMemoryError: Java heap space. The error…
-1
votes
1 answer

How to find the shortest path in a multi-route graph

Consider a graph with V vertices and n routes (cars). Each path (car) starts from one vertex and traverses the V vertices just one time (there is not any loop in each route). In each iteration (i.e., time), just one route (car) can be in each of…
-1
votes
1 answer

NullPointerException while cloning a graph using DFS iteratively

I am trying to clone a graph using DFS in Java iteratively, but on compiling it keeps on showing NullPointerException. I know the code using recursion is uch simpler, but wanted to try out in iterative way. The code is shown below: /** *…
-1
votes
1 answer

Find the shortest path that traverses through a required set of nodes and returns to the starting point

Suppose I have a set of edges in the form (where each tupe (i,j) is a directed edge from node i to node j): E=[(1, 6), (1, 7), (2, 3), (2, 6), (3, 2), (3, 8), (4, 5), (4, 7), (5, 4), (5, 9), (6, 1), (6, 7), (6, 2), (7, 1), (7, 6), (7, 4), (8, 9),…
Stoner
  • 846
  • 1
  • 10
  • 30
-1
votes
1 answer

traversing a graph in DFS order using stack

I'm trying to traverse a graph, iteratively, in dfs order. Below is the code I had. When I tested this, the output is NOT the same as the output of a recursive dfs (also included below). Can someone help debugging this? public static void…
One Two Three
  • 22,327
  • 24
  • 73
  • 114
-1
votes
2 answers

DFS to find all possible paths - Where am I going wrong?

I need to implement DFS to find all possible paths from a vertex, say "item" So far I have the following and I cannot understand where I am going wrong. void dfs() { int i; for(i=1;i<=nodecount;i++) { visited[i]=0; } …
user24603
  • 1
  • 3
-2
votes
1 answer

Is that a valid BFS?

I recently wrote a function to traverse a graph, along those lines: def traverse(batch: list[str], seen: set[str]): if not batch: return new_batch = [] for node in batch: print(node) new_batch.extend(n for n in…
Weier
  • 1,339
  • 1
  • 10
  • 20
-2
votes
1 answer

CosmosDB Gremlin API alternative for storing and processing Graph data

I currently use CosmosDB Gremlin API to store nodes and edges of an organization chart. To keep the data and occasional traversal, it is costing me minimum of $20 every month. Is there an alternative to CosmosDB Gremlin API which is cheaper and can…
-3
votes
1 answer

Getting neighbours in given distance BFS algorithm

I have to write a function that will return a set that contains neighbours of a source vertex in given distance. For example for exemplary graph: {0: [1, 3], 1: [2], 2: [], 3: [4], 4: [1, 5], 5:…
The Robcio
  • 33
  • 4
-4
votes
2 answers

how new traverse api works

nowadaya i m learning new traverse api of neo4j and i followed the link below http://neo4j.com/docs/stable/tutorial-traversal-java-api.html so now i know how to use uniqueness,evaluater etc. that is i know how to change beahviours of the api. but…
brtb
  • 2,201
  • 6
  • 34
  • 53
1 2 3
24
25