Home
Here you can read about the api of meshnetworkx
.
Provides the GraphZ class for storing a NetworkX graph in Zenoh.
Usage
import meshnetworkx as mx
GraphZ
Represents a NetworkX graph stored in Zenoh.
Source code in src/meshnetworkx/__init__.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
|
adj: dict[Any, dict[Any, dict[Any, Any]]]
property
Returns the adjacency list of the GraphZ object.
Returns:
Type | Description |
---|---|
dict[Any, dict[Any, dict[Any, Any]]]
|
The adjacency list. |
edges: nx.classes.reportviews.EdgeView
property
Returns a list of edges in the GraphZ object.
Returns:
Type | Description |
---|---|
EdgeView
|
A list of edges. |
nodes: NodeView
property
Returns a list of nodes in the GraphZ object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
If True, returns a list of tuples containing nodes and their data. |
required |
Returns:
Type | Description |
---|---|
NodeView
|
A list of nodes or a list of tuples containing nodes and their data. |
__init__()
Initializes the GraphZ object and connects to the Zenoh router.
Source code in src/meshnetworkx/__init__.py
71 72 73 74 75 76 77 78 79 80 |
|
__iter__()
Returns an iterator over the nodes in the GraphZ object.
Returns:
Type | Description |
---|---|
An iterator over the nodes. |
Source code in src/meshnetworkx/__init__.py
347 348 349 350 351 352 353 |
|
add_edge(u, v, **attr)
Adds an edge to the GraphZ object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
Any
|
The source node. |
required |
v
|
Any
|
The target node. |
required |
attr
|
Additional attributes for the edge. |
{}
|
Source code in src/meshnetworkx/__init__.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
add_node(node, **attr)
Adds a node to the GraphZ object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Any
|
The node to add. |
required |
attr
|
Additional attributes for the node. |
{}
|
Source code in src/meshnetworkx/__init__.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
add_nodes_from(nodes, **attr)
Add nodes from a list of nodes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes
|
list[Any]
|
The nodes to add. |
required |
**attr
|
The attributes to add to the nodes. |
{}
|
Source code in src/meshnetworkx/__init__.py
264 265 266 267 268 269 270 271 272 |
|
clear()
Clears all nodes from the GraphZ object.
Source code in src/meshnetworkx/__init__.py
338 339 340 341 |
|
close()
Closes the connection to the Zenoh router.
Source code in src/meshnetworkx/__init__.py
343 344 345 |
|
draw(block=True)
Draws the GraphZ object using NetworkX.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
block
|
bool
|
If True, blocks the drawing window. If False, does not block. |
True
|
Source code in src/meshnetworkx/__init__.py
355 356 357 358 359 360 361 362 363 |
|
from_networkx(g)
staticmethod
Creates a GraphZ object from a NetworkX graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g
|
Graph
|
A NetworkX graph. |
required |
Returns:
Type | Description |
---|---|
GraphZ
|
A GraphZ object. |
Source code in src/meshnetworkx/__init__.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
has_edge(u, v)
Checks if an edge exists in the GraphZ object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
Any
|
The source node. |
required |
v
|
Any
|
The target node. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the edge exists, False otherwise. |
Source code in src/meshnetworkx/__init__.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
has_node(node)
Checks if a node exists in the GraphZ object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Any
|
The node to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the node exists, False otherwise. |
Source code in src/meshnetworkx/__init__.py
298 299 300 301 302 303 304 305 306 307 308 |
|
remove_edge(u, v)
Removes an edge from the GraphZ object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
Any
|
The source node. |
required |
v
|
Any
|
The target node. |
required |
Source code in src/meshnetworkx/__init__.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
remove_node(node)
Removes a node from the GraphZ object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Any
|
The node to remove. |
required |
Source code in src/meshnetworkx/__init__.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
remove_nodes_from(nodes)
Removes nodes from the GraphZ object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes
|
list[Any]
|
The nodes to remove. |
required |
Source code in src/meshnetworkx/__init__.py
274 275 276 277 278 279 280 281 |
|
to_networkx()
Converts the GraphZ object to a NetworkX graph.
Returns:
Type | Description |
---|---|
Graph
|
A NetworkX graph. |
Source code in src/meshnetworkx/__init__.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
MeshNetworkXError
Bases: Exception
General exception for MeshNetworkX errors.
Source code in src/meshnetworkx/__init__.py
22 23 24 25 |
|
NodeView
Provides a read only view for accessing node data in a dictionary-like manner.
Source code in src/meshnetworkx/__init__.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
__call__(data=False)
Method-like access with optional arguments.
Source code in src/meshnetworkx/__init__.py
61 62 63 64 65 |
|
__getitem__(key)
Allow dictionary-like access.
Source code in src/meshnetworkx/__init__.py
53 54 55 |
|
__init__(node_data)
Initializes the NodeView object with node data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_data
|
dict[Any, Any]
|
A dictionary containing node data. |
required |
Source code in src/meshnetworkx/__init__.py
45 46 47 48 49 50 51 |
|
__setitem__(key, value)
Prevent assignment to the NodeView.
Source code in src/meshnetworkx/__init__.py
57 58 59 |
|