Skip to content
Advertisement

Tag: jgrapht

How to traverse a graph both “forwards” and “backwards”?

I am investigating Graphs/Graph Traversals using Using the code below I can create a simple graph and traverse it “forwards” However I would also like to be able to “retrace” my steps back through the graph from any vertex and return to the “start” of the graph. e.g. topologicalOrderIterator.previous() I cannot see any obvious methods within jgrapht-core? Is reverse Graph

How to draw a SimpleWeightedGraph on a JPanel?

I have a SimpleWeightedGraph and I want to draw it on a JPanel in a JFrame. Unfortunately nothing is drawn. I read this article. They are using a ListenableDirectedGraph so I tried a ListenableUndirectedGraph with no success. Answer It looks that you’re leaving some important details out of your question, and without a Minimal, Complete, and Verifiable example it is

Custom Edge with jgrapht

I want to define a custom edge But when I try to use the super()is that possible? What should I use for EdgeFactory when creating a graph? Would this be sufficient? Or should I create a new class who extends EdgeFactory as well? Answer You do not require to subclass DefaultWeightedEdge to create your custom edge, the following works also.

Advertisement