Re: [jgrapht-users] Impossible to set source and target of DefaultEdge
Brought to you by:
barak_naveh,
perfecthash
From: Anant R. <ar...@21...> - 2011-07-11 17:44:54
|
Hey Rob, Thanks for your response. I understand that EdgeFactories are much preferred to constructors and that graphs are used to query source and target, but in the case of DefaultEdge, I don't see how it's possible for the system to work. A factory that constructs DefaultEdges cannot set their source and target. And calling getEdgeSource() or getEdgeTarget() on a Graph<whatever,DefaultEdge> is essentially meaningless since every pair of DefaultEdges in the graph are equal(). I've investigated the source code a bit further, and DefaultEdge extends IntrusiveEdge, which has the source and target members' scope as package-private. So graph implementations provided by JGraphT itself (DefaultDirectedGraph, etc.) can (and do) set the source and target of DefaultEdges , and therefore can (and do) correctly implement getEdgeSource() and getEdgeTarget(). But for the rest of us, I think it's impossible to guarantee correctness of these two methods when Defaultedge is the edge type. Anant From: Rob Patro [mailto:rob...@gm...] Sent: Monday, July 11, 2011 12:07 PM To: jgr...@li... Subject: Re: [jgrapht-users] Impossible to set source and target of DefaultEdge Hi Anant, JGraphT is a very well designed library, but takes some getting used to at first. Edges are created using the EdgeFactors; raw Edges are not constructed. Then the src and target are queried via the graph in which the edge exists. --Rob On Jul 11, 2011 11:59 AM, "Anant Rathi" <ar...@21...<mailto:ar...@21...>> wrote: > All, > > org.jgrapht.graph.DefaultEdge has protected getSource() and getTarget() methods, but there aren't setters for source and target or a constructor that sets them. Whether you are instantiating or extending DefaultEdge, the source and target members can't be modified, and they're always null. That doesn't seem right. > > Am I missing something? > > Anant Rathi > Research Intern > 21st Century Technologies, Inc. > 6011 W. courtyard Drive > Building 5, Suite 300 > Austin, TX 78730 > > Phone: 512 682 4707<tel:512%20682%204707> > Email: ar...@21...<mailto:ar...@21...> > URL: http://www.21technologies.com > > The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose, nor disclose all or any part of its content to any other pserson. > |