Python networkx.OrderedDiGraph() Examples
The following are 11
code examples of networkx.OrderedDiGraph().
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: test_p2g.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_write_p2g(self): s = b"""foo 3 2 1 1 2 2 3 """ fh = io.BytesIO() G = nx.OrderedDiGraph() G.name = 'foo' G.add_edges_from([(1, 2), (2, 3)]) write_p2g(G, fh) fh.seek(0) r = fh.read() assert_equal(r, s)
Example #2
Source File: test_p2g.py From aws-kube-codesuite with Apache License 2.0 | 6 votes |
def test_write_p2g(self): s=b"""foo 3 2 1 1 2 2 3 """ fh=io.BytesIO() G=nx.OrderedDiGraph() G.name='foo' G.add_edges_from([(1,2),(2,3)]) write_p2g(G,fh) fh.seek(0) r=fh.read() assert_equal(r,s)
Example #3
Source File: test_graphs.py From pygsp with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_differential_operator(self, n_vertices=98): r"""The Laplacian must always be the divergence of the gradient, whether the Laplacian is combinatorial or normalized, and whether the graph is directed or weighted.""" def test_incidence_nx(graph): r"""Test that the incidence matrix corresponds to NetworkX.""" incidence_pg = np.sign(graph.D.toarray()) G = nx.OrderedDiGraph if graph.is_directed() else nx.OrderedGraph graph_nx = nx.from_scipy_sparse_matrix(graph.W, create_using=G) incidence_nx = nx.incidence_matrix(graph_nx, oriented=True) np.testing.assert_equal(incidence_pg, incidence_nx.toarray()) for graph in [graphs.Graph(np.zeros((n_vertices, n_vertices))), graphs.Graph(np.identity(n_vertices)), graphs.Graph([[0, 0.8], [0.8, 0]]), graphs.Graph([[1.3, 0], [0.4, 0.5]]), graphs.ErdosRenyi(n_vertices, directed=False, seed=42), graphs.ErdosRenyi(n_vertices, directed=True, seed=42)]: for lap_type in ['combinatorial', 'normalized']: graph.compute_laplacian(lap_type) graph.compute_differential_operator() L = graph.D.dot(graph.D.T) np.testing.assert_allclose(L.toarray(), graph.L.toarray()) test_incidence_nx(graph)
Example #4
Source File: bakefile.py From bake with ISC License | 5 votes |
def graph(self): if self._graph: return self._graph g = networkx.OrderedDiGraph() for task in self.tasks.values(): g.add_node(task) for dep in task.depends_on(): g.add_edge(task, dep) self._graph = g return self.graph
Example #5
Source File: test_ordered.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def test_digraph(): G = nx.OrderedDiGraph()
Example #6
Source File: test_convert.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_attribute_dict_integrity(self): # we must not replace dict-like graph data structures with dicts G = nx.OrderedGraph() G.add_nodes_from("abc") H = to_networkx_graph(G, create_using=nx.OrderedGraph) assert_equal(list(H.nodes), list(G.nodes)) H = nx.OrderedDiGraph(G) assert_equal(list(H.nodes), list(G.nodes))
Example #7
Source File: test_ordered.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_digraph(self): G = nx.OrderedDiGraph()
Example #8
Source File: test_ordered.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): self.G = nx.OrderedDiGraph() self.G.add_nodes_from([1, 2, 3]) self.G.add_edges_from([(2, 3), (1, 3)])
Example #9
Source File: test_convert.py From aws-kube-codesuite with Apache License 2.0 | 5 votes |
def test_attribute_dict_integrity(self): # we must not replace dict-like graph data structures with dicts G = nx.OrderedGraph() G.add_nodes_from("abc") H = to_networkx_graph(G, create_using=nx.OrderedGraph()) assert_equal(list(H.nodes), list(G.nodes)) H = nx.OrderedDiGraph(G) assert_equal(list(H.nodes), list(G.nodes))
Example #10
Source File: test_ordered.py From aws-kube-codesuite with Apache License 2.0 | 5 votes |
def test_digraph(): G = nx.OrderedDiGraph()
Example #11
Source File: test_ordered.py From aws-kube-codesuite with Apache License 2.0 | 5 votes |
def setUp(self): self.G = nx.OrderedDiGraph() self.G.add_nodes_from([1, 2, 3]) self.G.add_edges_from([(2, 3), (1, 3)])