File tree Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change 53
53
Zygote. @nograd vertex_pair_table
54
54
55
55
"""
56
- edge_index_table(adj[, num_E ])
56
+ edge_index_table(adj[, directed ])
57
57
58
58
Generate a mapping from vertex pair (i, j) to edge index. The edge indecies are determined by
59
59
the sorted vertex indecies.
60
60
"""
61
- function edge_index_table (adj:: AbstractVector{<:AbstractVector{<:Integer}} ,
62
- num_E= sum (map (length, adj)))
61
+ function edge_index_table (adj:: AbstractVector{<:AbstractVector{<:Integer}} , directed:: Bool = is_directed (adj))
63
62
table = Dict {Tuple{UInt32,UInt32},UInt64} ()
64
63
e = one (UInt64)
65
- for (i, js) = enumerate (adj)
66
- js = sort (js)
67
- for j = js
68
- table[(i, j)] = e
69
- e += one (UInt64)
64
+ if directed
65
+ for (i, js) = enumerate (adj)
66
+ js = sort (js)
67
+ for j = js
68
+ table[(i, j)] = e
69
+ e += one (UInt64)
70
+ end
71
+ end
72
+ else
73
+ for (i, js) = enumerate (adj)
74
+ js = sort (js)
75
+ js = js[i .≤ js]
76
+ for j = js
77
+ table[(i, j)] = e
78
+ table[(j, i)] = e
79
+ e += one (UInt64)
80
+ end
70
81
end
71
82
end
72
83
table
@@ -80,6 +91,8 @@ function edge_index_table(vpair::AbstractVector{<:Tuple})
80
91
table
81
92
end
82
93
94
+ edge_index_table (fg:: FeaturedGraph ) = edge_index_table (fg. graph, fg. directed)
95
+
83
96
Zygote. @nograd edge_index_table
84
97
85
98
function transform (X:: AbstractArray , vpair:: AbstractVector{<:Tuple} , num_V)
You can’t perform that action at this time.
0 commit comments