Returns a graph from a list of edges. Parameters ---------- edgelist : list or iterator Edge tuples create_using : EasyGraph graph constructor, optional (default=eg.Graph) Graph type to create. If graph instance, then cleared before populated. Examples ------
(edgelist, create_using=None)
| 261 | |
| 262 | |
| 263 | def from_edgelist(edgelist, create_using=None): |
| 264 | """Returns a graph from a list of edges. |
| 265 | |
| 266 | Parameters |
| 267 | ---------- |
| 268 | edgelist : list or iterator |
| 269 | Edge tuples |
| 270 | |
| 271 | create_using : EasyGraph graph constructor, optional (default=eg.Graph) |
| 272 | Graph type to create. If graph instance, then cleared before populated. |
| 273 | |
| 274 | Examples |
| 275 | -------- |
| 276 | >>> edgelist = [(0, 1)] # single edge (0,1) |
| 277 | >>> G = eg.from_edgelist(edgelist) |
| 278 | |
| 279 | or |
| 280 | |
| 281 | >>> G = eg.Graph(edgelist) # use Graph constructor |
| 282 | |
| 283 | """ |
| 284 | G = eg.empty_graph(0, create_using) |
| 285 | G.add_edges_from(edgelist) |
| 286 | return G |
| 287 | |
| 288 | |
| 289 | def to_networkx(g: "Union[Graph, DiGraph]") -> "Union[nx.Graph, nx.DiGraph]": |
no test coverage detected