Re: [jgrapht-developers] Adding multiple edges and loops
Brought to you by:
barak_naveh,
perfecthash
From: Michael B. <beh...@in...> - 2004-09-20 12:14:54
|
=2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Montag, 20. September 2004 03:39 schrieb Barak Naveh: > i think it is consistent and fine. > > here is my resoning: > > adding a forbidden loop is a mistake that violates the graph consistency > (if it forbid such loops). the graph should then throw an exception to > "defend" itself from begin corrupted. > > for a similar reason, if the user tries to "forcibly" add multiple edges = to > graph that forbids multiple edges (this can be done by abusing the > addEdge(Edge e) method) then an exception should be thrown -- the graph > needs to defend its consistency. if this is not currently the case, it > should be fixed. This is currently not the case. addEdge(e) behaves exactly like=20 addEdge(e.getSource(), e.getTarget()). It throws exception on forbidden loops and silently ignores forbidden multiple edges.=20 > > However, if the user attempts to add an edge which is already existing > using addEdge(v1,v2), then it is not a mistake. he or she wants to include > the specified edge in the edge set. if the edge already in the edge set, > there is nothing to do. if it is not, it is included. in other words, the > call can satisfy the user wish, without violating any graph consistency > criteria and therefore there is no reason to throw an exception. > > is my reasoning making sense? Partly. I think it is more reasonible to let addEdge(e) behave exactly=20 like addEdge(v1, v2), because on graphs with multiple edges allowed your argumentation would fail. What does the user want when calling addEdge(v1,v2) when such an edge is already present. Add another=20 one or just ensure that an edge is present? I think a user calling=20 addEdge really wants to add an Edge and following your reasoning both versions of addEdge should always throw an exception when the=20 two vertices are already connected and multiedges are forbidden. Michael =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBTsm2ZDyR4hR8HnQRAnnAAKDeSkYacrhMzdUwUR6b/WYUfvz8tACgm4KR imbIcMfgyBhuEl46zacCn1A=3D =3D/grz =2D----END PGP SIGNATURE----- |