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
# The `label_type` argument defines how vertices will be referred to, it can be anything but an integer type (to avoid confusion with codes, see below). The `vertex_data_type` and `edge_data_type` type determine what kind of data will be associated with each vertex and edge. Finally, `graph_data` can contain an arbitrary object associated with the graph as a whole.
28
22
29
-
#However, since this constructor receives types as keyword arguments, it is type-unstable. Casual users may not care, but if your goal is performance, you should use either of the following alternatives:
30
-
# 1. Wrap the constructor in a function
31
-
#2. Switch to positional arguments (be careful with the order!)
23
+
#### Type stability
24
+
25
+
#However, since this constructor receives types as keyword arguments, it is type-unstable. Casual users may not care, but if your goal is performance, you might need one of the following alternatives: either wrap the constructor in a function...
32
26
33
27
functioncolors_constructor()
34
28
returnMetaGraph(
35
29
Graph();
36
30
label_type=Symbol,
37
31
vertex_data_type=NTuple{3,Int},
38
-
edge_data_type=String,
32
+
edge_data_type=Symbol,
39
33
graph_data="additive colors",
40
34
)
41
35
end
42
36
37
+
colors_constructor()
38
+
43
39
@test@inferredcolors_constructor() == colors #src
44
40
45
-
#-
41
+
# ... or switch to positional arguments (be careful with the order!)
# 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.
72
68
73
-
colors[:red, :green] ="yellow";
74
-
colors[:red, :blue] ="magenta";
75
-
colors[:green, :blue] ="cyan";
69
+
colors[:red, :green] =:yellow;
70
+
colors[:red, :blue] =:magenta;
71
+
colors[:green, :blue] =:cyan;
72
+
73
+
# ### Creating a non-empty graph
74
+
75
+
# There is a final constructor we haven't mentioned, which allows you to build and fill the `MetaGraph` in one fell swoop. Here's how it works:
0 commit comments