Python networkx.reverse() Examples
The following are 6
code examples of networkx.reverse().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
networkx
, or try the search function
.
Example #1
Source File: graph.py From angr with BSD 2-Clause "Simplified" License | 6 votes |
def shallow_reverse(g): """ Make a shallow copy of a directional graph and reverse the edges. This is a workaround to solve the issue that one cannot easily make a shallow reversed copy of a graph in NetworkX 2, since networkx.reverse(copy=False) now returns a GraphView, and GraphViews are always read-only. :param networkx.DiGraph g: The graph to reverse. :return: A new networkx.DiGraph that has all nodes and all edges of the original graph, with edges reversed. """ new_g = networkx.DiGraph() new_g.add_nodes_from(g.nodes()) for src, dst, data in g.edges(data=True): new_g.add_edge(dst, src, **data) return new_g
Example #2
Source File: graph.py From angr with BSD 2-Clause "Simplified" License | 6 votes |
def __init__(self, graph, entry_node, successors_func=None, reverse=False): self._l = logging.getLogger("utils.graph.dominators") self._graph_successors_func = successors_func self._reverse = reverse # Set it to True to generate a post-dominator tree. # Temporary variables self._ancestor = None self._semi = None self._label = None # Output self.dom = None self.prepared_graph = None self._construct(graph, entry_node)
Example #3
Source File: graph.py From angr with BSD 2-Clause "Simplified" License | 5 votes |
def __init__(self, graph, entry_node, successors_func=None): super().__init__(graph, entry_node, successors_func=successors_func, reverse=True)
Example #4
Source File: test_unary.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def test_reverse1(): # Other tests for reverse are done by the DiGraph and MultiDigraph. G1=nx.Graph() assert_raises(nx.NetworkXError, nx.reverse, G1)
Example #5
Source File: test_unary.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_reverse1(): # Other tests for reverse are done by the DiGraph and MultiDigraph. G1 = nx.Graph() assert_raises(nx.NetworkXError, nx.reverse, G1)
Example #6
Source File: test_unary.py From aws-kube-codesuite with Apache License 2.0 | 5 votes |
def test_reverse1(): # Other tests for reverse are done by the DiGraph and MultiDigraph. G1=nx.Graph() assert_raises(nx.NetworkXError, nx.reverse, G1)