-
Notifications
You must be signed in to change notification settings - Fork 22
Doubling the weights of self-edges #38
Comments
This is expected (if not explicitly intended) for undirected graphs, as the adjacency matrix of an undirected graph yields
gives
|
Sorry, I'm at loss as to how the adjacency matrix comes in here, I'm new to the graph terminology. How is the adjacency matrix related to the weights in this context? Am I on the right track to think that And a related question, what would be the recommended way to construct a weighted graph that I expected to get in the first place? That is |
SimpleWeightedGraphs are stored as a sparse matrix with non-zero weights denoting adjacencies. Self-loops are a bit of an afterthought and aren't guaranteed to actually work with all algorithms. However, what you can do is simply iterate over the vertices and divide the weights by two, readding the edges. A PR would also be welcome, if for nothing else than discussion as to the best way to proceed. |
I'm trying to construct a weighted graph with self-edges using the
SimpleWeightedGraph(srcs, dsts, weights)
constructor from here but the weights of self-edges seem to be counted twice. For examplealthough the edge 1=>1 was specified only once. This is coming from
vcat
duplicating[1]
into[1,1]
for source, destination and the weight ending up in a double self-edge. So currently there is no way to use this constructor to get a self-edge with weight 1 (assuming integer input weights).I don't know if this was intended, if not it could be fixed with the code below.
The text was updated successfully, but these errors were encountered: