ArgumentException in UndirectedEdge constructor
See original GitHub issueI’m probably missing something in the inner workings of the library, but I can’t understand why there is the need to make sure that Source is “lower” (whatever that might mean, since we are working on arbitrary structures) than Target when constructing a new UndirectedEdge (and in fact there are specialized edge comparers that test if source == source && target == target OR source == target && target == source).
Would it work if I were to implement a CompareTo
function that always returns 0?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Edge of undirected graph in Java
Suppose I am writing a Java class to represent an edge of undirected graph. This class Edge contains two vertices to and from...
Read more >Undirected graph data structure in C# - ...
and since V doesn't change after being set in the constructor, ... Length)) throw new ArgumentException("Invalid node number specified.
Read more >ArgumentException Constructor (System)
Initializes a new instance of the ArgumentException class with a specified error message, the parameter name, and a reference to the inner exception...
Read more >In this assignment, you will add functionality to the Graph ...
Add a constructor UndirectedGraph() that reads in a File object for a ... Illegal ArgumentException: Cannot add directed edge to undirected graph 12:06...
Read more >Class AsUndirectedGraph<V,E>
An undirected view of the backing directed graph specified in the constructor. This graph allows modules to apply algorithms designed for undirected graphs ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Personally, I find it more disturbing to have to be careful about order in an undirected edge (and, even more disturbing, having
Source
andTarget
properties in an undirected structure), but that’s my problem 😄I understand it comes from the need to have a common structure between all edge types so, it’s all good for me.
In any case I’ve already sorted it out (pun intended) on my side by using a static method that compares the two vertices and calls the constructor with parameters in the right order.
Glad to hear you find a way to make it working on your end 😉