Re: [jgrapht-users] getAllEdges for DirectedGraph
Brought to you by:
barak_naveh,
perfecthash
From: John S. <js...@gm...> - 2013-03-18 15:20:49
|
Oh, sorry, I forgot about that; the Javadoc is correct. For the least amount of code, you can use http://jgrapht.org/javadoc/org/jgrapht/alg/DijkstraShortestPath.html#findPathBetween(org.jgrapht.Graph, V, V) If you are going to be making lots of tests on the same graph, then use FloydWarshallShortestPaths instead. On Mon, Mar 18, 2013 at 5:35 AM, Robert Manning <rob...@gm...> wrote: > That works, sort of. Reading the javadoc it indicates that edge directions > are ignored for a DirectedGraph. And in my test I can flip "A" and "C" and > pathExists still returns true. I am trying to model Maven downstream > project dependencies. Is there no way to have the path test respect edge > directions ? > > Rob > > > On Fri, Mar 15, 2013 at 9:27 PM, John Sichi <js...@gm...> wrote: >> >> Anyway, to get back to your original problem...if you just want to >> test whether such a sequence of edges exists (without identifying >> them), you can use ConnectivityInspector.pathExists. Otherwise, you >> can use one of the traversal iterators such as DFS or BFS to find an >> arbitrary path, or one of the shortest-path algorithms if you care >> about path length. >> >> On Fri, Mar 15, 2013 at 5:39 PM, John Sichi <js...@gm...> wrote: >> > JGraphT is not just for DAG's. >> > >> > On Mar 15, 2013 5:33 PM, "Robert Manning" <rob...@gm...> >> > wrote: >> >> >> >> Somehow, in a DAG that makes no sense to me ? >> >> >> >> Rob >> >> >> >> On Fri, Mar 15, 2013 at 5:35 PM, Tobias Dehling >> >> <de...@wi...> wrote: >> >>> >> >>> There could be multiple edge between two vertices. getEdge will get >> >>> you >> >>> one of them and getAllEdges will return all of them. >> >>> >> >>> Tobias >> >>> >> >>> >> >>> On 03/15/2013 10:31 PM, Robert Manning wrote: >> >>> >> >>> I guess if getAllEdges and getEdge do the same thing, then that's >> >>> fine. >> >>> By why the duplication? Why have getAllEdges when you can simply call >> >>> getEdge ? >> >>> >> >>> Rob >> >>> >> >>> On Fri, Mar 15, 2013 at 4:59 PM, Alex Moir >> >>> <am...@di...> wrote: >> >>>> >> >>>> It looks to me like you don’t have an edge from A to C, except >> >>>> through >> >>>> B. And I think getAllEdges() only returns direct links between >> >>>> vertices. >> >>>> Maybe you are looking for a getAllPaths() type method? >> >>>> >> >>>> >> >>>> >> >>>> Alex >> >>>> >> >>>> >> >>>> >> >>>> From: Robert Manning [mailto:rob...@gm...] >> >>>> Sent: Friday, March 15, 2013 8:59 AM >> >>>> To: jgr...@li... >> >>>> Subject: [jgrapht-users] getAllEdges for DirectedGraph >> >>>> >> >>>> >> >>>> >> >>>> Hello, >> >>>> >> >>>> I am trying to use jgrapht to answer the question : for any two >> >>>> vertices >> >>>> in a directed acyclic graph, tell me if there is a set of edges that >> >>>> connects the two. Based on the javadoc for getAllEdges in the Graph >> >>>> interface, it seemed like jgrapht could answer this question for me. >> >>>> However, my testing seems to prove otherwise: >> >>>> >> >>>> @Test >> >>>> public void testGetAllEdges() { >> >>>> >> >>>> DirectedGraph<String, DefaultEdge> g = new >> >>>> DefaultDirectedGraph<String, DefaultEdge>(DefaultEdge.class); >> >>>> >> >>>> g.addVertex("A"); >> >>>> g.addVertex("B"); >> >>>> g.addVertex("C"); >> >>>> >> >>>> g.addEdge("A", "B"); >> >>>> g.addEdge("B", "C"); >> >>>> >> >>>> Set<DefaultEdge> edges = g.getAllEdges("A", "C"); >> >>>> >> >>>> assertFalse("There was no set of edges connecting A to C", >> >>>> edges.isEmpty()); >> >>>> >> >>>> } >> >>>> >> >>>> Of course, "edges" is an empty set in my test. What am I doing >> >>>> wrong? >> >>>> >> >>>> Rob >> >>> >> >>> >> >>> >> >>> >> >>> >> >>> >> >>> ------------------------------------------------------------------------------ >> >>> Everyone hates slow websites. So do we. >> >>> Make your web apps faster with AppDynamics >> >>> Download AppDynamics Lite for free today: >> >>> http://p.sf.net/sfu/appdyn_d2d_mar >> >>> >> >>> >> >>> >> >>> _______________________________________________ >> >>> jgrapht-users mailing list >> >>> jgr...@li... >> >>> https://lists.sourceforge.net/lists/listinfo/jgrapht-users >> >>> >> >>> >> >>> >> >>> -- >> >>> Dipl.-Wirt.-Inf. Tobias Dehling >> >>> >> >>> Universität zu Köln >> >>> Seminar für Wirtschaftsinformatik und Systementwicklung >> >>> Juniorprofessur für Information Systems Quality >> >>> Juniorprofessor Dr. Ali Sunyaev >> >>> Wirtschafts- und Sozialwissenschaftliche Fakultät >> >>> >> >>> Pohligstr. 1, 50969 Köln >> >>> >> >>> Tel: +49 221 470-5383 (Durchwahl) >> >>> +49 221 470-5368 (Sekretariat) >> >>> Fax: +49 221 470-5386 >> >>> Mail: de...@wi... >> >>> Web: www.isq.uni-koeln.de >> >>> >> >>> >> >>> >> >>> >> >>> ------------------------------------------------------------------------------ >> >>> Everyone hates slow websites. So do we. >> >>> Make your web apps faster with AppDynamics >> >>> Download AppDynamics Lite for free today: >> >>> http://p.sf.net/sfu/appdyn_d2d_mar >> >>> _______________________________________________ >> >>> jgrapht-users mailing list >> >>> jgr...@li... >> >>> https://lists.sourceforge.net/lists/listinfo/jgrapht-users >> >>> >> >> >> >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> Everyone hates slow websites. So do we. >> >> Make your web apps faster with AppDynamics >> >> Download AppDynamics Lite for free today: >> >> http://p.sf.net/sfu/appdyn_d2d_mar >> >> _______________________________________________ >> >> jgrapht-users mailing list >> >> jgr...@li... >> >> https://lists.sourceforge.net/lists/listinfo/jgrapht-users >> >> >> > > > |