RadCluster
Graph-based cluster dynamics for irradiated materials
Loading...
Searching...
No Matches
Functions | Variables
py_utils.core.to_networkx Namespace Reference

Functions

str vertex (Population pop, int n)
 
range _sizes (Population pop, int n_max)
 
 to_networkx (ReactionAdmissibilityGraph rag, int n_max=40, bool include_binary=True)
 
None write_graphml (G, path)
 
str structural_report (ReactionAdmissibilityGraph rag, int n_max=40)
 

Variables

 ap
 
 type
 
 int
 
 default
 
 help
 
 choices
 
 action
 
 Path
 
 a = ap.parse_args()
 
 inp
 
 rag
 
 _
 
 equations
 
 cascade
 
str report = structural_report(rag, n_max=a.n_max)
 
 encoding
 
 G
 

Detailed Description

core/to_networkx.py — explicit materialization of a RAG for diagnostics.

Host-independent.  The production path keeps the reaction admissibility
graph *implicit*: an :class:`Edge` is a size-parameterized family, and the
graph walker never instantiates a vertex.  That is the right choice for the
inner loop (see the paper, Section "Implementation"), but it means the
standard structural queries — connectivity, reachability from the monomer
pools, orphaned vertices, cycle structure — are not available for free.

This module supplies them by exporting the declared graph, truncated at a
chosen size cut-off, into an explicit ``networkx.MultiDiGraph``.  It is a
DIAGNOSTIC path only: nothing in the solver imports it, and NetworkX is an
optional dependency.

Typical use::

    from py_utils.materials import build_eurofer_rag
    from py_utils.core.to_networkx import to_networkx, structural_report

    rag, layout = build_eurofer_rag(inp, rr)
    G = to_networkx(rag, n_max=40)
    print(structural_report(rag, n_max=40))

Cite as: NetworkX, Hagberg, Schult & Swart, Proc. SciPy 2008.

Function Documentation

◆ _sizes()

range py_utils.core.to_networkx._sizes ( Population  pop,
int  n_max 
)
protected

Definition at line 44 of file to_networkx.py.

◆ structural_report()

str py_utils.core.to_networkx.structural_report ( ReactionAdmissibilityGraph  rag,
int   n_max = 40 
)
Human-readable structural audit of a declared RAG.

Reports vertex/edge counts, weak connectivity, the set of vertices not
reachable from the monomer pools (a declaration bug: population with no
production channel), and the set with no outgoing edge (a sink-only
trap).  Intended to be run once per host declaration and quoted in the
paper, not called during integration.

Definition at line 205 of file to_networkx.py.

◆ to_networkx()

py_utils.core.to_networkx.to_networkx ( ReactionAdmissibilityGraph  rag,
int   n_max = 40,
bool   include_binary = True 
)
Materialize ``rag`` up to size ``n_max`` as a ``networkx.MultiDiGraph``.

Parameters
----------
rag : ReactionAdmissibilityGraph
    The host's declared graph.
n_max : int
    Size cut-off.  Keep it small (tens): the binary edge classes are
    O(n_max**2) per family, which is exactly why the production path
    does not materialize the graph at all.
include_binary : bool
    Expand COALESCENCE and ANNIHILATION families.  These are directed
    *hyperedges* (two precursors); NetworkX has no hyperedge type, so
    each is represented by its two tail->head arcs, both tagged
    ``hyperedge=True`` and sharing a ``hyper_id``.  Set False for a
    cleaner drawing.

Returns
-------
networkx.MultiDiGraph
    Node attributes: ``polarity``, ``population``, ``size``.
    Edge attributes: ``edge_class``, ``label``, ``kernel``,
    ``hyperedge``, ``hyper_id``.

Definition at line 51 of file to_networkx.py.

◆ vertex()

str py_utils.core.to_networkx.vertex ( Population  pop,
int  n 
)
Canonical string key for the vertex (polarity, size, population).

Definition at line 39 of file to_networkx.py.

◆ write_graphml()

None py_utils.core.to_networkx.write_graphml (   G,
  path 
)
Write ``G`` to GraphML, dropping attributes GraphML cannot represent.

``to_networkx`` tags every arc with ``hyper_id``, which is ``None`` on
the unary edge classes because they are not hyperedge members, and
``kernel`` is ``None`` for any edge the host declared without one.
The GraphML writer rejects ``None`` outright ("GraphML writer does not
support <class 'NoneType'> as data values"), so exporting the graph
unmodified always fails.  Attributes are dropped rather than coerced:
an absent ``hyper_id`` is what "not a hyperedge" means, and writing a
sentinel would invite a reader to treat it as an id.

The input graph is not modified.

Definition at line 176 of file to_networkx.py.

Variable Documentation

◆ _

py_utils.core.to_networkx._
protected

Definition at line 292 of file to_networkx.py.

◆ a

py_utils.core.to_networkx.a = ap.parse_args()

Definition at line 288 of file to_networkx.py.

◆ action

py_utils.core.to_networkx.action

Definition at line 281 of file to_networkx.py.

◆ ap

py_utils.core.to_networkx.ap
Initial value:
1= argparse.ArgumentParser(
2 description="Materialize and audit the EUROFER-97 reaction "
3 "admissibility graph.")

Definition at line 270 of file to_networkx.py.

◆ cascade

py_utils.core.to_networkx.cascade

Definition at line 293 of file to_networkx.py.

◆ choices

py_utils.core.to_networkx.choices

Definition at line 278 of file to_networkx.py.

◆ default

py_utils.core.to_networkx.default

Definition at line 273 of file to_networkx.py.

◆ encoding

py_utils.core.to_networkx.encoding

Definition at line 298 of file to_networkx.py.

◆ equations

py_utils.core.to_networkx.equations

Definition at line 293 of file to_networkx.py.

◆ G

py_utils.core.to_networkx.G
Initial value:
1= to_networkx(rag, n_max=a.n_max,
2 include_binary=not a.no_binary)

Definition at line 301 of file to_networkx.py.

◆ help

py_utils.core.to_networkx.help

Definition at line 274 of file to_networkx.py.

◆ inp

py_utils.core.to_networkx.inp
Initial value:
1= InputData(I=a.I, V=a.V,
2 physics_option=f"full_CD_{a.cascade}")

Definition at line 290 of file to_networkx.py.

◆ int

py_utils.core.to_networkx.int

Definition at line 273 of file to_networkx.py.

◆ Path

py_utils.core.to_networkx.Path

Definition at line 284 of file to_networkx.py.

◆ rag

py_utils.core.to_networkx.rag

Definition at line 292 of file to_networkx.py.

◆ report

str py_utils.core.to_networkx.report = structural_report(rag, n_max=a.n_max)

Definition at line 295 of file to_networkx.py.

◆ type

py_utils.core.to_networkx.type

Definition at line 273 of file to_networkx.py.