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
4
votes
1 answer

Neo4j Traversal Framework Expander and Ordering

I am trying to understand Neo4J java traversal API but after a thorough reading I am stuck on certain points. What I seem to know: Difference between PathExpander and BranchOrderingPolicy. As per my understanding, the former tells what…
mickeymoon
  • 4,820
  • 5
  • 31
  • 56
4
votes
2 answers

Find all BFS/DFS traversals

Given an undirected cyclic graph, I want to find all possible traversals with Breadth-First search or Depth-First search. That is given a graph as an adjacency-list: A-BC B-A C-ADE D-C E-C So all BFS paths from root A would…
Madnebular
  • 43
  • 1
  • 4
3
votes
1 answer

Code to find the shortest path in Breadth First Search

#Breadth First Search graph = { 'S' : ['A','B'], 'A' : ['B','C','D'], 'B' : ['C'], 'C' : ['D'], 'D' : [] } visited = [] queue = [] goal = 'D' def bfs(visited, graph, node): visited.append(node) queue.append(node) while…
3
votes
0 answers

2 Shortest Paths in Weighted Directed Graph without Intersection

I will try to make clear analogy: There is a city with N destinations. It is represented by weighted and directed graph where weights are distances as minutes. There are 2 people which don't want to be in same destination at same time. They are…
3
votes
1 answer

Finding maximum number of nodes in set of undirected graphs

I have a set of nodes (N=7) {a, b, c, d, e, f, g} These nodes form one or more distinct undirected graphs, I want to find the graph with the maximum number of nodes. However, I have a constraint that the complexity can not be more than (N*M) where…
3
votes
0 answers

Memoizing traversal over a cyclic graph

I have a directed graph that is cyclic in general, and I want to find relationships between nodes and sinks. Traversals over directed graphs seem to be well-suited for memoization with recursion, since the graph can be mapped to the results of the…
concat
  • 3,107
  • 16
  • 30
3
votes
3 answers

All pairs all paths on a graph

This is possibly a problem with possibly no optimal solution. Suppose I have a directed graph, have no clue whether it has any cycles or not(cycle detection will be one of the aspects of this problem). Given a set of vertices(possibly millions of…
sc_ray
  • 7,803
  • 11
  • 63
  • 100
3
votes
2 answers

Get array's first item as object in TinkerPop3 Gremlin query and JanusGraph

I faced this issue during a migration of gremlin queries from v2 to v3. V2-way: inE().has(some condition).outV().map().toList()[0] will return an object. This is wrapped in transform{label: it./etc/} step. V3-way, still WIP: inE().has(some…
amankkg
  • 4,503
  • 1
  • 19
  • 30
3
votes
0 answers

Return multiple fields from a Solr Cloud graph traversal query

I'm using Solr to create user-based recommendations. I'm running a solr cloud stream query using the gatherNodes function. The query itself is working fine, but it only returns one field (the itemId). In the end, I'm looking to be able to return…
Benya16
  • 177
  • 1
  • 15
3
votes
2 answers

Neo4j graph backtracking algorithm

I have a complex question about Neo4j and what Traversal can do. Imagine you have the following Neo4j graph My idea is to traverse the whole graph, and if I find a 'false' node, expand this status to his neighbours and so on, and finally in this…
jpadilladev
  • 1,756
  • 4
  • 16
  • 23
3
votes
1 answer

Tinkerpop/Gremlin Breadth first traversal

I'm trying to traverse a graph to trace the lineage of a specific node. I would like my query to yield the antecedents to that node in a breadth first pattern. Note, each node can have multiple parents. The Graph can be many layers deep and I'd like…
veekay33210
  • 141
  • 4
3
votes
1 answer

Gremlin .match()

I have a query in Gremlin, using Datastax studio that looks like this: g.V().has('vertexLabel', 'vertexProperty1', '12345').match( __.as('d').in('edgeLabel1').values('property2').as('NAME1'), …
3
votes
1 answer

Gremlin- How to compute percentage of vertices with a certain property

I am trying to use a single gremlin query to determine the percentage of vertices that satisfy a certain predicate, but I'm having trouble storing and propagating the computed values. Say I want to compute the percentage of all vertices with label…
3
votes
0 answers

OrientDb graph TRAVERSE between two vertex with conditions

This is my graph schema (little part): BusStation is class which extends V (Vertex). Every BusStation element has stationId property with some value (1,2,3,4,5...). Bus is class which extends E (Edge). Every Bus element has three…
Juraj Ćutić
  • 206
  • 2
  • 10
3
votes
2 answers

Arangodb AQL recursive graph traversal

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…
Alice Smith
  • 81
  • 1
  • 9
1 2
3
24 25