-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathstatic_graph.jl
More file actions
36 lines (29 loc) · 815 Bytes
/
static_graph.jl
File metadata and controls
36 lines (29 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
g = DiGraph{Node{String}, Edge{Node{String}}}()
add_node!(g, "a")
add_node!(g, "b")
add_edge!(g, "a", "b")
@test length(nodes(g)) == 2
@test length(edges(g)) == 1
@test out_edges(g, "a") == in_edges(g, "b")
@test is_directed(g) == true
g2 = EvolvingGraph{Node{String}, String}()
add_edge!(g2, "a", "b", "t1")
add_edge!(g2, "b", "c", "t1")
add_edge!(g2, "c", "d", "t2")
add_edge!(g2, "a", "b", "t2")
g3 = aggregate_graph(g2)
display(g3)
A = adjacency_matrix(g3)
@test A[1,2] == 1
@test A[2,3] == 1
@test num_nodes(g3) == 4
@test num_edges(g3) == 3
# add a graph to an evolving graph
g = DiGraph{Node{String}, Edge{Node{String}}}()
add_node!(g, "1")
add_node!(g, "2")
add_edge!(g, "1", "2")
eg = EvolvingGraph{Node{String}, Int}()
add_graph!(eg, g, 1)
@test length(nodes(eg)) == 2
@test length(edges(eg)) == 1