Construct a `Graph`. Args: nodes: Location `Tensor` or `Geometry` objects representing the nodes. edges: Connectivity and edge value `Tensor`. boundary: Named boundary sets. Returns: `Graph`
(nodes: Union[Geometry, Tensor],
edges: Tensor,
boundary: Dict[str, Dict[str, slice]] = None,
build_distances=True, # remaining for legacy reasons. Now evaluated on demand.
build_bounding_distance=False)
| 143 | |
| 144 | |
| 145 | def graph(nodes: Union[Geometry, Tensor], |
| 146 | edges: Tensor, |
| 147 | boundary: Dict[str, Dict[str, slice]] = None, |
| 148 | build_distances=True, # remaining for legacy reasons. Now evaluated on demand. |
| 149 | build_bounding_distance=False) -> Graph: |
| 150 | """ |
| 151 | Construct a `Graph`. |
| 152 | |
| 153 | Args: |
| 154 | nodes: Location `Tensor` or `Geometry` objects representing the nodes. |
| 155 | edges: Connectivity and edge value `Tensor`. |
| 156 | boundary: Named boundary sets. |
| 157 | |
| 158 | Returns: |
| 159 | `Graph` |
| 160 | """ |
| 161 | if isinstance(nodes, Tensor): |
| 162 | assert 'vector' in channel(nodes) and channel(nodes).get_item_names('vector') is not None, f"nodes must have a 'vector' dim listing the physical dimensions but got {shape(nodes)}" |
| 163 | nodes = Point(nodes) |
| 164 | boundary = {} if boundary is None else boundary |
| 165 | return Graph(nodes, edges, boundary) |