| Conditions | 5 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | from enum import Enum |
||
| 27 | @classmethod |
||
| 28 | def of(cls, graph: nx.Graph) -> Self: |
||
| 29 | """Determine the graph type based on structure and properties. |
||
| 30 | |||
| 31 | Args: |
||
| 32 | graph (nx.Graph): A NetworkX graph object. |
||
| 33 | |||
| 34 | Returns: |
||
| 35 | GraphType: An instance of this Enum matching the input graph. |
||
| 36 | """ |
||
| 37 | if graph.is_directed() and graph.is_multigraph(): |
||
| 38 | return cls.MultiDiGraph |
||
| 39 | elif graph.is_directed(): |
||
| 40 | return cls.DiGraph |
||
| 41 | elif graph.is_multigraph(): |
||
| 42 | return cls.MultiGraph |
||
| 43 | else: |
||
| 44 | return cls.Graph |
||
| 45 |