Comments (3)
This is expected (if not explicitly intended) for undirected graphs, as the adjacency matrix of an undirected graph yields 2
for self-loops:
g = Graph(3)
add_edge!(g, 1, 1)
Matrix(adjacency_matrix(g))
gives
2 0 0
0 0 0
0 0 0
from simpleweightedgraphs.jl.
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 SimpleWeightedGraph(srcs, dsts, weights)
is conceptually equivalent to creating a directed graph first and then converting it to an undirected one by summing all the edges, where self edges are counted twice because their adjacency matrix entry is 2?
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 SimpleWeightedGraph(srcs, dsts, weights)
without doubling the self-edges? Currently I directly construct the sparse matrix and build a weighted graph with it.
from simpleweightedgraphs.jl.
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.
from simpleweightedgraphs.jl.
Related Issues (20)
- Cartesian products are not extended to SimpleWeightedGraphs HOT 3
- `ne` fails to count the correct number of self-edges HOT 3
- Potential problem with Pagerank for SimpleWeightedDiGraphs
- Removing an edge just sets the edge weight to 0 HOT 4
- gplot(::SimpleWeightedGraph) not working HOT 4
- Support for complex weights HOT 2
- Weighted `degree` HOT 16
- Inconsistent adjacency matrix for weighted and unweighted graphs HOT 1
- No weighted node functionality? HOT 2
- Error: Non symmetric matrices created by repeated pairs HOT 2
- Ambiguity error on pagerank HOT 3
- Register v1.1.1 HOT 6
- transitiveclosure not supported HOT 3
- Why G.weights is the transpose of adjacent_matrix(G) HOT 7
- Neighbors related functions give wrong result after `rem_edge!` because it just set edge weight to 0 HOT 8
- Direction of edges inverted when going from `SimpleWeightedDiGraph` to `SimpleDiGraph` HOT 2
- distance calculation with a_star fails with SimpleWeightedGraph and SimpleWeightedDiGraph HOT 1
- updating docs: get_weight(graph, src, dst) returns weight of an edge
- biconnected_components HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simpleweightedgraphs.jl.