Skip to content

Commit 47620ed

Browse files
committed
Refactor reverse function to use rem_edges.
1 parent 6cd667d commit 47620ed

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

src/abstractdatagraph.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using Dictionaries: Indices, set!, unset!
22
using Graphs: Graphs, AbstractEdge, IsDirected, a_star, add_edge!, add_vertex!, edges,
33
indegree, induced_subgraph, ne, nv, outdegree, steiner_tree, vertices
44
using NamedGraphs.GraphsExtensions: GraphsExtensions, add_edges!, add_vertices!,
5-
arrange_edge, incident_edges, is_edge_arranged, vertextype
5+
arrange_edge, incident_edges, is_edge_arranged, rem_edges, vertextype
66
using NamedGraphs.OrdinalIndexing: OrdinalSuffixedInteger
77
using NamedGraphs.SimilarType: similar_type
88
using NamedGraphs: NamedGraphs, AbstractEdges, AbstractNamedEdge, AbstractNamedGraph,
@@ -262,12 +262,7 @@ function GraphsExtensions.rename_vertices(f::Function, graph::AbstractDataGraph)
262262
end
263263

264264
function Base.reverse(graph::AbstractDataGraph)
265-
reversed_graph = similar_graph(graph, vertices(graph))
266-
for v in vertices(graph)
267-
if isassigned(graph, v)
268-
reversed_graph[v] = graph[v]
269-
end
270-
end
265+
reversed_graph = rem_edges(graph, edges(graph))
271266
for e in edges(graph)
272267
add_edge!(reversed_graph, reverse(e))
273268
if isassigned(graph, e)

0 commit comments

Comments
 (0)