Skip to content

Commit 0b90f82

Browse files
committed
Avoid warning logs: Don't add edges between excluded nodes to graph copy
1 parent 6dd71e7 commit 0b90f82

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Code/Graph+Copying.swift

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ extension Graph
3232

3333
for originalEdge in includedEdges ?? Set(edgesByID.values)
3434
{
35+
guard graphCopy.contains(originalEdge.source.id),
36+
graphCopy.contains(originalEdge.target.id) else { continue }
37+
3538
graphCopy.addEdge(from: originalEdge.source.id,
3639
to: originalEdge.target.id,
3740
count: originalEdge.count)

Code/Graph/Graph.swift

+5
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ public class Graph<NodeID: Hashable, NodeValue>
145145
nodesByID.values.filter { $0.isSink }
146146
}
147147

148+
public func contains(_ nodeID: NodeID) -> Bool
149+
{
150+
node(for: nodeID) != nil
151+
}
152+
148153
public func contains(_ node: Node) -> Bool
149154
{
150155
self.node(for: node.id) === node

0 commit comments

Comments
 (0)