Skip to content

Commit f0e16cf

Browse files
committed
Update empty!
1 parent dd98466 commit f0e16cf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/bipartite_graph.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,15 @@ function BipartiteGraph(nsrcs::T, ndsts::T; metadata=nothing) where T
100100
end
101101

102102
Base.eltype(::Type{<:BipartiteGraph{I}}) where I = I
103-
Base.empty!(g::BipartiteGraph) = (foreach(empty!, g.fadjlist); foreach(empty!, g.badjlist); g.ne = 0; g)
103+
function Base.empty!(g::BipartiteGraph)
104+
foreach(empty!, g.fadjlist)
105+
foreach(empty!, g.badjlist)
106+
g.ne = 0
107+
if g.metadata !== nothing
108+
foreach(empty!, g.metadata)
109+
end
110+
g
111+
end
104112
Base.length(::BipartiteGraph) = error("length is not well defined! Use `ne` or `nv`.")
105113

106114
if isdefined(LightGraphs, :has_contiguous_vertices)

0 commit comments

Comments
 (0)