Adjacency list representation of a graph.
| 41 | |
| 42 | |
| 43 | class AdjacencyList(Generic[Index]): |
| 44 | """Adjacency list representation of a graph.""" |
| 45 | |
| 46 | _cpp_object: ( |
| 47 | _cpp.graph.AdjacencyList_int32 |
| 48 | | _cpp.graph.AdjacencyList_int64 |
| 49 | | _cpp.graph.AdjacencyList_int_sizet_int8__int32_int32 |
| 50 | ) |
| 51 | |
| 52 | def __init__( |
| 53 | self, |
| 54 | g: ( |
| 55 | _cpp.graph.AdjacencyList_int32 |
| 56 | | _cpp.graph.AdjacencyList_int64 |
| 57 | | _cpp.graph.AdjacencyList_int_sizet_int8__int32_int32 |
| 58 | ), |
| 59 | ): |
| 60 | """Creates a Python wrapper for the exported adjacency list class. |
| 61 | |
| 62 | Note: |
| 63 | Do not use this constructor directly. Instead use |
| 64 | :func:`adjacencylist`. |
| 65 | |
| 66 | Args: |
| 67 | g: The underlying cpp instance that this object will wrap. |
| 68 | """ |
| 69 | self._cpp_object = g |
| 70 | |
| 71 | def __repr__(self): |
| 72 | """String representation of the adjacency list.""" |
| 73 | return self._cpp_object.__repr__() |
| 74 | |
| 75 | def links(self, node: int) -> npt.NDArray[Index]: |
| 76 | """Retrieve the links of a node. |
| 77 | |
| 78 | Note: |
| 79 | This is available only for adjacency lists with no |
| 80 | additional link (edge) data. |
| 81 | |
| 82 | Args: |
| 83 | node: Node to retrieve the connectivity of. |
| 84 | |
| 85 | Returns: |
| 86 | Neighbors of the node. |
| 87 | """ |
| 88 | return self._cpp_object.links(node) |
| 89 | |
| 90 | @property |
| 91 | def array(self) -> npt.NDArray[Index]: |
| 92 | """Array representation of the adjacency list. |
| 93 | |
| 94 | Note: |
| 95 | This is available only for adjacency lists with no |
| 96 | additional link (edge) data. |
| 97 | |
| 98 | Returns: |
| 99 | Flattened array representation of the adjacency list. |
| 100 | """ |
no outgoing calls
no test coverage detected