You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome to `MetaGraphsNext.jl`, an experimental, type-stable replacement for [MetaGraphs](https://github.com/JuliaGraphs/MetaGraphs.jl).
7
-
8
-
## Getting started
9
-
10
-
To see how the package works, take a look at the tutorial in the [documentation](https://juliagraphs.org/MetaGraphsNext.jl/dev/). We first explain [the basics](tutorial_basics.md) of the `MetaGraph` structure, before moving on to its [integration](tutorial_graphs.md) with `Graphs.jl`.
7
+
Welcome to MetaGraphsNext, an experimental, type-stable replacement for [MetaGraphs](https://github.com/JuliaGraphs/MetaGraphs.jl). This package will let you store metadata on the vertices and edges of your graphs. Take a look at the [documentation](https://juliagraphs.org/MetaGraphsNext.jl/dev/) to learn more!
Copy file name to clipboardExpand all lines: docs/src/index.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,10 @@ Welcome to `MetaGraphsNext.jl`, an experimental, type-stable replacement for [Me
4
4
5
5
## Getting started
6
6
7
-
To see how the package works, take a look at the tutorial. We first explain [the basics](tutorial_basics.md) of the `MetaGraph` structure, before moving on to its [integration](tutorial_graphs.md) with `Graphs.jl`.
7
+
To install the package, open the Julia REPL and type
8
8
9
-
## Index
10
-
11
-
```@index
12
-
Modules = [MetaGraphsNext]
9
+
```julia
10
+
julia>using Pkg; Pkg.add("MetaGraphsNext")
13
11
```
12
+
13
+
The tutorial provides an overview of the functionalities. We first explain the [basics](tutorial_basics.md) of the `MetaGraph` structure, before moving on to its [integration](tutorial_graphs.md) with `Graphs.jl`.
Meta graph based on a {0, 0} undirected simple Int64 graph with vertices indexed by Symbol(s), String(s) vertex metadata, Symbol(s) edge metadata, "special" as graph metadata, and default weight 1.0
Meta graph based on a {0, 0} undirected simple Int64 graph with vertex labels of type Symbol, vertex metadata of type String, edge metadata of type Symbol, graph metadata given by "graph_of_colors", and default weight 1.0
16
16
```
17
17
18
-
## Adding and modifying vertices
18
+
## Modifying the graph
19
19
20
-
Use `setindex!` (as you would do with a dictionary) to add a new vertex with the given metadata. If a vertex with the given label does not exist, it will be created automatically. Otherwise, `setindex!` will modify the metadata for the existing vertex.
20
+
Modifications of graph elements and the associated metadata can always be done using `setindex!` (as in a dictionary) with the relevant labels.
21
+
22
+
### Vertices
23
+
24
+
Use `setindex!` with one key to add a new vertex with the given label and metadata. If a vertex with the given label does not exist, it will be created automatically. Otherwise, the function will simply modify the metadata for the existing vertex.
21
25
22
26
```jldoctest example
23
27
julia> colors[:red] = "warm";
24
28
25
29
julia> colors[:yellow] = "warm";
26
30
31
+
julia> colors[:blue] = "warm"; # wrong metadata
32
+
27
33
julia> colors[:blue] = "cool";
28
34
```
29
35
30
-
##Using vertex codes
36
+
### Edges
31
37
32
-
In the absence of removal, vertex codes correspond to order of insertion in the underlying graph:
38
+
Use `setindex!` with two keys to add a new edge between the given labels and containing the given metadata. Beware that this time, nonexistent labels will throw an error.
33
39
34
40
```jldoctest example
35
-
julia> code_for(colors, :red)
36
-
1
41
+
julia> colors[:red, :yellow] = :orange;
37
42
38
-
julia> code_for(colors, :blue)
39
-
3
43
+
julia> colors[:red, :blue] = :violet;
44
+
45
+
julia> colors[:yellow, :blue] = :green;
40
46
```
41
47
42
-
You can retrieve the associated labels as follows:
48
+
## Accessing graph properties
49
+
50
+
To retrieve graph properties, we still follow a dictionary-like interface based on labels.
51
+
52
+
### Existence
53
+
54
+
To check the presence of a vertex or edge, use `haskey`:
You can access and change the metadata using indexing: zero arguments for graph metadata, one label for vertex metadata, and two labels for edge metadata.
72
+
All kinds of metadata can be accessed with `getindex`:
55
73
56
74
```jldoctest example
57
75
julia> colors[]
58
-
"special"
59
-
60
-
julia> colors[:blue] = "very cool";
76
+
"graph_of_colors"
61
77
62
78
julia> colors[:blue]
63
-
"very cool"
79
+
"cool"
64
80
65
-
julia> colors[:red, :yellow] = :orange;
66
-
67
-
julia> colors[:red, :yellow]
68
-
:orange
81
+
julia> colors[:yellow, :blue]
82
+
:green
69
83
```
70
84
71
-
Checking the presence of a vertex or edge can be done with `haskey`:
72
-
73
-
```jldoctest example
74
-
julia> haskey(colors, :red)
75
-
true
76
-
77
-
julia> haskey(colors, :green)
78
-
false
85
+
## Using vertex codes
79
86
80
-
julia> haskey(colors, :red, :yellow)
81
-
true
87
+
In the absence of removal, vertex codes correspond to order of insertion in the underlying graph:
82
88
83
-
julia> haskey(colors, :yellow, :red) # undirected graph, so vertex order doesn't matter
84
-
true
89
+
```jldoctest example
90
+
julia> code_for(colors, :red)
91
+
1
85
92
86
-
julia> haskey(colors, :red, :green)
87
-
false
93
+
julia> code_for(colors, :blue)
94
+
3
88
95
```
89
96
90
-
## Deleting vertices and edges
91
-
92
-
You can delete vertices and edges with `delete!`.
97
+
You can retrieve the associated labels as follows:
93
98
94
99
```jldoctest example
95
-
julia> delete!(colors, :red, :yellow);
100
+
julia> label_for(colors, 1)
101
+
:red
96
102
97
-
julia> delete!(colors, :blue);
103
+
julia> label_for(colors, 3)
104
+
:blue
98
105
```
99
106
100
107
## Adding weights
101
108
102
109
The most simple way to add edge weights is to speficy a default weight for all of them.
You can use the `weightfunction` keyword to specify a function which will
113
-
transform edge metadata into a weight. This weight must always be the same
114
-
type as the `defaultweight`.
121
+
You can use the `weight_function` keyword to specify a function which will transform edge metadata into a weight. This weight must always be the same type as the `default_weight`.
0 commit comments