https://github.com/quantumbfs/multigraphs.jl
A multigraph extension of Graphs.jl
https://github.com/quantumbfs/multigraphs.jl
Last synced: 8 months ago
JSON representation
A multigraph extension of Graphs.jl
- Host: GitHub
- URL: https://github.com/quantumbfs/multigraphs.jl
- Owner: QuantumBFS
- License: mit
- Created: 2020-02-15T07:17:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-27T15:31:33.000Z (about 3 years ago)
- Last Synced: 2025-09-19T12:41:19.070Z (9 months ago)
- Language: Julia
- Homepage:
- Size: 43.9 KB
- Stars: 31
- Watchers: 3
- Forks: 6
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Multigraphs
[](https://github.com/QuantumBFS/Multigraphs.jl/actions)
[](https://codecov.io/gh/QuantumBFS/Multigraphs.jl)
Multigraphs extension for `Graphs.jl`.
## Installation
Multigraphs is a
Julia Language
package. To install Multigraphs,
please open
Julia's interactive session (known as REPL) and press ] key in the REPL to use the package mode, then type the following command
```julia
pkg> add Multigraphs
```
## Examples
```julia
julia> using Graphs, Multigraphs
# create a undirected multigraph with 3 vertices and 0 multiple edges
# use DiMultigraph for directed multigraphs
julia> mg = Multigraph(3)
{3, 0} undirected Int64 multigraph with Int64 multiplicities
# add a multiple edge from 1 to 2 with multiplicity 2
julia> add_edge!(mg, 1, 2, 2)
true
# add a simple edge (multiple edge with multiplicity 1) from 2 to 3
julia> add_edge!(mg, 2, 3)
true
# this will increase multiplicity of the edge from 2 to 3 by 2
julia> add_edge!(mg, 2, 3, 2)
true
# this will decrease multiplicity of the edge from 2 to 3 by 1
julia> rem_edge!(mg, 2, 3, 2)
# here me is a MultipleEdge
julia> mes = [me for me in edges(mg)]
2-element Array{MultipleEdge{Int64,Int64},1}:
Multiple edge 1 => 2 with multiplicity 2
Multiple edge 2 => 3 with multiplicity 1
# here e is a Graphs.SimpleEdge
julia> for e in mes[1]
println(e)
end
Edge 1 => 2
Edge 1 => 2
```
## License
MIT License