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)
| 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. |
no outgoing calls