Skip to content

GraphView with hidden_nodes and hidden_edges - #2512

Closed
dschult wants to merge 1 commit into
networkx:masterfrom
dschult:graphview
Closed

dschult wants to merge 1 commit into
networkx:masterfrom
dschult:graphview

Conversation

@dschult

@dschult dschult commented Jul 12, 2017

Copy link
Copy Markdown
Member

This implements a restricted view on graphs where hidden_nodes and hidden_edges do not appear in the resulting graph. This implementation is read-only though you could change the original graph and the restricted view would update accordingly. At this point you can't update the hidden_nodes and hidden_edges without creating a new view. I might add that feature if I can come up with a good way to do it.

Related tickets include:
#762
#1011
#793
#335
and there are probably many other places where this feature has been discussed.

@dschult dschult added this to the networkx-2.0 milestone Jul 12, 2017
@hagberg

hagberg commented Jul 15, 2017

Copy link
Copy Markdown
Member

Looks good - doesn't this feature belong as a (more general) subgraph view? That is, a subgraph where you specify the edges and/or nodes you want to view. Depending on the application it could be easier to specify inclusion or exclusion.

@dschult

dschult commented Jul 16, 2017

Copy link
Copy Markdown
Member Author

I wondered about that too. Should they be the same object? (specifying either include or exclude nodes and either include or exclude edges) Or does it make more sense to have one set of objects for exclude and one for include?

Would the name SubGraphView`` be better? also excluded_nodesvshidden_nodes```?

Finally, we could have the user provide a node_filter function that determines which nodes get through and another for edges? Lots of ways to do all this...

@dschult

dschult commented Jul 17, 2017

Copy link
Copy Markdown
Member Author

I've been looking at how best to make a SubGraphView interface. Sometimes we want to exclude specific nodes. Other times we want to include only specific nodes. It'd be nice to be able to do either with a single interface. It would not be hard to have the user supply one function for nodes and another for edges. If the function returns True then that node/edge is in the subgraph. Otherwise it isn't. This puts the onus on the user to come up with a function and storage mechanism even for simple cases. Maybe we can supply some helper functions/objects to make that process easier. I'm thinking of the filter function inputs as (Graph, node) and (Graph, edge-tuple) with bool return value.

I found a description of filters which might provide a basis for how to make a helper object. Users provide includeonly_filters and exclude_filters for each of nodes and edges. If one is not provided that condition is ignored. If the user provides a set instead of a function, we treat that set as the included/excluded values.

Does this approach seem simple enough to pursue?

@dschult

dschult commented Jul 18, 2017

Copy link
Copy Markdown
Member Author

I prefer #2523 to this proposal.

@dschult dschult closed this Jul 18, 2017
@dschult
dschult deleted the graphview branch July 29, 2017 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants