Repository navigation
Add examples to docstrings of subgraph_(iso/monomorphism) methods - #7622
Conversation
dschult
left a comment
There was a problem hiding this comment.
Nice!
I found a typo. And I wonder if we can make the nodes more clearly part of G or H by avoiding small integers for one of the graphs. see below
| >>> G = nx.DiGraph([(1, 2), (2, 1), (2, 3), (3, 2)]) | ||
| >>> H = nx.DiGraph(nx.path_graph(5)) |
There was a problem hiding this comment.
The nodes here make it hard to see if a mapping is from H to G or from G to H.
Could we use G = nx.DiGraph([("A", "B"), ("B", "C"), ("B", "A"), ("C", "B")])?
Then the result is something like: {0: 'A', 1: 'B', 2: 'C'}
Another choice could be: G = nx.DiGraph([(101, 102), (102, 101), (102, 103), (103, 102)])
Also, would it be simpler to make the graphs directed paths:
G = nx.DiGraph([("A", "B"), ("B", "C")])
H = nx.DiGraph(nx.path_graph(5).edges)But maybe that isn't simpler... it removes one direction from each node-pair. But the constructor syntax is longer.
Co-authored-by: Dan Schult <[email protected]>
Co-authored-by: Dan Schult <[email protected]>
b204ba5 to
21f88d8
Compare
dschult
left a comment
There was a problem hiding this comment.
I'm sorry that I didn't catch this before. But the last three intro phrases for examples are "Check whether...." when they should be "Yield ... mappings ".
Addresses #7615
Adds examples to the
subgraph_is_(iso/mono)morphicandsubgraph_(iso/mono)morophism_iterto highlight the role that argument order plays when constructing the GraphMatcher objects.After some back and forth, I ultimately decided to do a separate docstring for each of the 8 methods. This means I added stubs for the
DiGraphMatchermethods for the sole purpose of updating the docstrings. I had tried adding both a directed and undirected example to theGraphMatchermethods (which are then inherited and thus don't need to be duplicated), but decided against it for the subjective reason that I thought the examples section got too long when I did so. One solution would be to make shorter examples... I'm happy to give that a stab as well if it's preferred --- feedback welcome!This PR also includes a few minor rst cleanups and comment removals.