JGraphT - how to modify graph with Topological sort (not asking how to iterate topologically!) - jgrapht

Does JGraphT has ability to run a Topological Sort on a graph that will purge forward edges (or at least label them as such) and the resulting graph will have accessible root list of nodes (top level nodes of all trees in the graph)

Related

What will be the visited node list for this graph below using A* Algorithm

What would be the visited nodes and path for this layout using A* (Order Alphabetically and if two goals have identical cost then G_2 is preferred). I am getting the path SDHJABCEHJFG_1 but not sure about it and the path too?

Depth/Breadth First Search Traversal

I am using gremlin with AWS Neptune, and for certain reasons, I want to traverse the graph in either depth-first or breadth-first manner (doesn't matter). This is what I am doing currently:
g.V('0').repeat(out('connected_to').dedup().where(without('z')).aggregate('z')).until(out('connected_to').dedup().where(without('z')).count().is(0)).select('z').limit(1).unfold()
I know that a path exists from vertex '0' to every other vertex in the graph, but there may be cycles in the graph and so, I use the Collection 'z' to keep track of visited nodes, making sure I do not revisit such a node.
If this were to work, I would have all 1000 vertices of the graph in 'z' at the end. But that isn't the case. I get 600 vertices and some vertices are missing even though they have clear incoming edges from other vertices that are in 'z'. What's wrong with my logic here?

How to create a graph with sugraph with jgrapht

I want to create a graph with subgraphs (I think cluster is a synonymous - not sure ?). Someone could explain how to create this type of graph and how to export this composite graph. I readed this post Creating graph with clusters using jgrapht but i am not sure to understand this sentence "You could create a graph where each vertex is a graph by itself; edges between these vertices represent relations between these special vertices.". Does it mean that in this case verticles are relations between subgraphs. How to build this verticles? Thanks
In JGraphT, vertices and edges are arbitrary objects: a Graph<V,E> consists of vertices of type V, and edges of type E. See the wiki guide https://jgrapht.org/guide/UserOverview for details.
So you could simply define a graph where V is also a graph: Graph<Graph<String,DefaultEdge>,DefaultEdge>. In this example, each vertex in the graph, is a graph by itself, consisting of String vertices and DefaultEdge edges.

Dgraph: Deep graph traversal possible with recurse?

I have a couple of questions regarding the capabilities of Dgraph regarding graph traversal.
Let's say we have a dataset that consists of nodes of the type post. Each post can have n posts that are replies to this post. The depth of this tree is not limited.
Is it possible with Dgraph to search trough all leaf nodes starting from one starting node and return all leafs that fulfill a certain condition?
Is it possible to set a depth limit to not end up with a gigantic dataset?
Is it also possible to find the children of all parent nodes that fulfill a certain condition?
And finally: Are edges in Dgraph directed? And can I include that in the query?
Author of Dgraph here.
Is it possible with Dgraph to search trough all leaf nodes starting
from one starting node and return all leafs that fulfill a certain
condition?
Yes. You could use the recurse directive (https://docs.dgraph.io/query-language/#recurse-query).
Is it possible to set a depth limit to not end up with a gigantic
dataset?
Yes. Recursion supports a maximum depth.
Is it also possible to find the children of all parent nodes that fulfill a certain condition?
Yes. You can traverse an edge, and put a filter on it. https://docs.dgraph.io/query-language/#applying-filters
And finally: Are edges in Dgraph directed? And can I include that in the query?
Edges in dgraph are directed. But, Dgraph also supports a "reverse" index, which can be used to automatically generate the edges in the reverse direction. You can then traverse these reverse edges, by adding a tilde (~) in front of the predicate name.
https://docs.dgraph.io/query-language/#reverse-edges

C code for finding all paths between two nodes in a given undirected graph

I want a C code for finding all the paths between two given nodes in an unweighted undirected graph covering all the vertices where vertices can be repeated but not edges
Use Warshall's algorithm to solve the problem.

Resources