You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,11 +96,11 @@ graph.removeEdge(from: node1.id, to: node2.id)
96
96
`Graph` offers many ways to query its nodes, node IDs, values and edges. Have a look into [Graph.swift](https://github.com/codeface-io/SwiftNodes/blob/master/Code/Graph/Graph.swift) to see them all. In addition, `GraphNode` has caches that enable quick access to its neighbours:
97
97
98
98
```swift
99
-
node.descendants// all nodes to which there is an edge from node
100
-
node.ancestors// all nodes from which there is an edge to node
101
-
node.neighbours// all descendants and ancestors
102
-
node.isSink// whether node has no descendants
103
-
node.isSource// whether node has no ancestors
99
+
node.descendants// all nodes to which there is an edge from node
100
+
node.ancestors// all nodes from which there is an edge to node
Many algorithms produce a variant of a given graph. Rather than modifying the original graph, SwiftNodes suggests to make a copy.
119
+
Many algorithms produce a variant of a given graph. Rather than modifying the original graph, SwiftNodes suggests to copy it.
120
120
121
121
A `graph.copy()` is identical to the original `graph` in IDs, values and structure but contains its own new node- and edge objects. You may also copy just a subset of a graph and limit the included edges and/or nodes:
122
122
@@ -145,17 +145,17 @@ SwiftNodes has begun to accumulate [some graph algorithms](https://github.com/co
145
145
146
146
### Condensation Graph
147
147
148
-
`graph.makeCondensationGraph()` creates the [condensation graph](https://en.wikipedia.org/wiki/Strongly_connected_component) of the `graph`, which is the graph in which all [strongly connected components](https://en.wikipedia.org/wiki/Strongly_connected_component) of the original graph have been collapsed into single nodes, so the resulting condensation graph is acyclic.
148
+
`graph.makeCondensationGraph()` creates the [condensation graph](https://en.wikipedia.org/wiki/Strongly_connected_component) of the `graph`, which is the graph in which all [strongly connected components](https://en.wikipedia.org/wiki/Strongly_connected_component) of the original `graph` have been collapsed into single nodes, so the resulting condensation graph is acyclic.
149
149
150
150
### Minimum Equivalent Graph
151
151
152
152
`graph.makeMinimumEquivalentGraph()` creates the [MEG](https://en.wikipedia.org/wiki/Transitive_reduction) of the `graph`. This only works on acyclic graphs and might even hang or crash on cyclic ones.
153
153
154
154
### Ancestor Counts
155
155
156
-
`graph.findNumberOfNodeAncestors()` returns a `[(Node, Int)]` containing each node of the graph associated with its ancestor count. The ancestor count is the number of all (recursive) ancestors of the node. Basically, it's the number of other nodes from which the node can be reached.
156
+
`graph.findNumberOfNodeAncestors()` returns a `[(Node, Int)]` containing each node of the `graph` together with its ancestor count. The ancestor count is the number of all (recursive) ancestors of the node. Basically, it's the number of other nodes from which the node can be reached.
157
157
158
-
This only works on acyclic graphs right now and might return incorrect results for some nodes in cyclic graphs.
158
+
This only works on acyclic graphs right now and might return incorrect results for nodes in cycles.
159
159
160
160
Ancestor counts can serve as a proxy for [topological sorting](https://en.wikipedia.org/wiki/Topological_sorting).
161
161
@@ -165,7 +165,7 @@ Here is the internal architecture (composition and essential dependencies) of th
165
165
166
166

167
167
168
-
The above image was created with the [Codeface](https://www.codeface.io) app.
168
+
The above image was created with [Codeface](https://www.codeface.io).
0 commit comments