MCPcopy
hub / github.com/networkx/networkx / clear

Method clear

networkx/classes/graph.py:1548–1566  ·  view source on GitHub ↗

Remove all nodes and edges from the graph. This also removes the name, and all graph, node, and edge attributes. Examples -------- >>> G = nx.path_graph(4) # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.clear() >>> list(G.nodes) []

(self)

Source from the content-addressed store, hash-verified

1546 return DegreeView(self)
1547
1548 def clear(self):
1549 """Remove all nodes and edges from the graph.
1550
1551 This also removes the name, and all graph, node, and edge attributes.
1552
1553 Examples
1554 --------
1555 >>> G = nx.path_graph(4) # or DiGraph, MultiGraph, MultiDiGraph, etc
1556 >>> G.clear()
1557 >>> list(G.nodes)
1558 []
1559 >>> list(G.edges)
1560 []
1561
1562 """
1563 self._adj.clear()
1564 self._node.clear()
1565 self.graph.clear()
1566 nx._clear_cache(self)
1567
1568 def clear_edges(self):
1569 """Remove all edges from the graph without altering nodes.

Callers 15

_clear_cacheFunction · 0.45
clear_edgesMethod · 0.45
test_iteratorsMethod · 0.45
test_clearMethod · 0.45
test_clearMethod · 0.45
write_dotFunction · 0.45
read_dotFunction · 0.45
empty_graphFunction · 0.45
_johnson_cycle_searchFunction · 0.45
make_clique_bipartiteFunction · 0.45
max_weight_matchingFunction · 0.45
gap_heuristicFunction · 0.45

Calls

no outgoing calls

Tested by 6

test_iteratorsMethod · 0.36
test_clearMethod · 0.36
test_clearMethod · 0.36