xnetwork namespace

View Classes provide node, edge and degree "views" of a graph.

Views for nodes, edges and degree are provided for all base graph classes. A view means a read-only object that is quick to create, automatically updated when the graph changes, and provides basic access like n : V, for n : V, V[n] and sometimes set operations.

The views are read-only iterable containers that are updated as the graph is updated. As with dicts, the graph should not be updated while (iterating through the view. Views can be iterated multiple times.

Edge and Node views also allow data attribute lookup. The resulting attribute dict is writable as gra.edges[3, 4]["color"]="red" Degree views allow lookup of degree values for single nodes. Weighted degree is supported with the weight argument.

NodeView

`V = gra.nodes` (or `V = gra.nodes()`) allows `len(V)`, `n : V`, set
operations e.g. "gra.nodes & H.nodes", and `dd = gra.nodes[n]`, where
`dd` is the node data dict. Iteration is over the nodes by default.

NodeDataView

To iterate over (node, data) pairs, use arguments to `gra.nodes()`
to create a DataView e.g. `DV = gra.nodes(data="color", default="red")`.
The DataView iterates as `for n, color : DV` and allows
`(n, "red"] : DV`. Using `DV = gra.nodes(data=true)`, the DataViews
use the full datadict : writeable form also allowing contain testing as
`(n, {"color": "red"}] : VD`. DataViews allow set operations when
data attributes are hashable.

DegreeView

`V = gra.degree` allows iteration over (node, degree) pairs as well
as lookup: `deg=V[n]`. There are many flavors of DegreeView
for In/Out/Directed/Multi. For Directed Graphs, `gra.degree`
counts both : and out going edges. `gra.out_degree` &&
`gra.in_degree` count only specific directions.
Weighted degree using edge data attributes is provide via
`V = gra.degree(weight="attr_name")` where any string with the
attribute name can be used. `weight=None` is the default.
No set operations are implemented for degrees, use NodeView.

The argument `nbunch` restricts iteration to nodes : nbunch.
The DegreeView can still lookup any node even if (nbunch is specified.

EdgeView

`V = gra.edges` or `V = gra.edges()` allows iteration over edges as well as
`e : V`, set operations and edge data lookup `dd = gra.edges[2, 3]`.
Iteration is over 2-tuples `(u, v)` for Graph/DiGraph. For multigraphs
edges 3-tuples `(u, v, key)` are the default but 2-tuples can be obtained
via `V = gra.edges(keys=false)`.

Set operations for directed graphs treat the edges as a set of 2-tuples.
For undirected graphs, 2-tuples are not a unique representation of edges.
So long as the set being compared to contains unique representations
of its edges, the set operations will act as expected. If the other
set contains both `(0, 1)` and `(1, 0)` however, the result of set
operations may contain both representations of the same edge.

EdgeDataView

Edge data can be reported using an EdgeDataView typically created
by calling an EdgeView: `DV = gra.edges(data="weight", default=1)`.
The EdgeDataView allows iteration over edge tuples, membership checking
but no set operations.

Iteration depends on `data` and `default` and for multigraph `keys`
If `data == false` (the default) then iterate over 2-tuples `(u, v)`.
If `data is true` iterate over 3-tuples `(u, v, datadict)`.
Otherwise iterate over `(u, v, datadict.get(data, default))`.
For Multigraphs, if (`keys is true`, replace `u, v` with `u, v, key`
to create 3-tuples and 4-tuples.

The argument `nbunch` restricts edges to those incident to nodes : nbunch.

Exceptions

Base exceptions and errors for XNetwork.

Classes

template<typename nodeview_t, typename adjlist_t = py::dict<Value_type<nodeview_t>, int>, typename adjlist_outer_dict_factory = py::dict<Value_type<nodeview_t>, adjlist_t>>
class DiGraphS
template<typename _nodeview_t, typename adjlist_t = py::set<Value_type<_nodeview_t>>, typename adjlist_outer_dict_factory = py::dict<Value_type<_nodeview_t>, adjlist_t>>
class Graph
template<typename nodeview_t>
class NodeView
struct XNetworkException
struct XNetworkError
struct XNetworkPointlessConcept
struct XNetworkAlgorithmError
struct XNetworkUnfeasible
struct XNetworkNoPath
struct XNetworkNoCycle
struct HasACycle
struct XNetworkUnbounded
struct XNetworkNotImplemented
struct NodeNotFound
struct AmbiguousSolution
struct ExceededMaxIterations
class XNetwork
A class for saying hello in multiple languages.

Enums

enum class LanguageCode { EN, DE, ES, FR }

Typedefs

using SimpleDiGraphS = DiGraphS<decltype(py::range<uint32_t>(uint32_t{})), py::dict<uint32_t, int>, std::vector<py::dict<uint32_t, int>>>
using SimpleGraph = Graph<decltype(py::range<uint32_t>(uint32_t{})), py::set<uint32_t>, std::vector<py::set<uint32_t>>>

Enum documentation

enum class xnetwork::LanguageCode

Language codes to be used with the XNetwork class

Typedef documentation

using xnetwork::SimpleDiGraphS = DiGraphS<decltype(py::range<uint32_t>(uint32_t{})), py::dict<uint32_t, int>, std::vector<py::dict<uint32_t, int>>>

using xnetwork::SimpleGraph = Graph<decltype(py::range<uint32_t>(uint32_t{})), py::set<uint32_t>, std::vector<py::set<uint32_t>>>