Comments (5)
They should just work as long as you've got a :weight
attribute on the edges.
(:weight
is the default attribute for weights, you can use weightfield!()
to change it.)
from metagraphs.jl.
@sbromberger Thanks, I was not even aware, could you point to the code part(s) that make(s) it work?
I have an incoming PR for a flow-like algorithm in LG, and I would definitively love to have it work with MetaGraphs from the start.
(I will close the issue as soon as I have no more reason to bother you, sorry)
from metagraphs.jl.
Sure. Take a look at the README.md towards the end to see how the weights work in MetaGraphs:
# using weights
julia> mg = MetaGraph(CompleteGraph(3))
{3, 3} undirected Int64 metagraph with Float64 weights defined by :weight (default weight 1.0)
julia> enumerate_paths(dijkstra_shortest_paths(mg, 1), 3)
2-element Array{Int64,1}:
1
3
julia> set_prop!(mg, 1, 2, :weight, 0.2)
Dict{Symbol,Float64} with 1 entry:
:weight => 0.2
julia> set_prop!(mg, 2, 3, :weight, 0.6)
Dict{Symbol,Float64} with 1 entry:
:weight => 0.6
julia> enumerate_paths(dijkstra_shortest_paths(mg, 1), 3)
3-element Array{Int64,1}:
1
2
3
Then, in https://github.com/JuliaGraphs/MetaGraphs.jl/blob/130f60c0fab66fa183da1cf65bfbae93f6b66cc4/src/MetaGraphs.jl#L108, we override weights()
, which is used by any LightGraphs function that can handle weights (graph types can override the default "all weights = 1" structure, which is what we do here.) See https://github.com/JuliaGraphs/LightGraphs.jl/blob/f8b5589bd5bef1d71a3806082f125f8f1cb67d8b/src/centrality/closeness.jl#L14 for an example.
That said, the existing flow algorithms don't use weights
, they use capacity and residual matrices. We might want to revisit that.
from metagraphs.jl.
That said, the existing flow algorithms don't use weights, they use capacity and residual matrices. We might want to revisit that.
I think it would be really nice.
As for my incoming PR, it also uses weights on the vertices, so I will have to be creative, but I will make it compatible with MetaGraphs. Should we let the issue opened while flow algorithms are not yet using weights
?
from metagraphs.jl.
Should we let the issue opened while flow algorithms are not yet using
weights
?
Not here, but there should probably be an issue in LightGraphs for discussion.
from metagraphs.jl.
Related Issues (20)
- Error : cannot assign a value to variable LightGraphs.Graph from module Main HOT 2
- Use getproperty() to access a meta graph vertex via a label index HOT 5
- feature request: need `squash()` for MetaGraph and MetaDiGraph HOT 1
- weight matrix error in the function `dijkstra_shortest_paths()`
- Feature Request: Extend `rem_vertices!` to MetaGraphs
- Roadmap to 1.0? HOT 3
- Property of edge lost when going from MetaDiGraph with inversed edge direction to MetaGraph HOT 2
- JLD2 compat for v0.3 HOT 1
- Directed Graphs HOT 2
- set_prop! returns Set{Symbol} if an indexing property is being set
- Register v0.6.7 HOT 5
- Disallow construction of `MetaGraph` from directed graph? HOT 3
- Metaweight filters for shortest path routing on attributes
- `rem_vertices!` missing
- `add_vertex!` fails if setting multiple indexing properties using a `Dict`
- How to update vertex / node color in a loop HOT 1
- Register 0.6.4 HOT 1
- Register v0.6.5 HOT 7
- Multi-threading with MetaGraphs HOT 1
- Method to check whether an index exists (`has_indexing_prop`)
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 metagraphs.jl.