Graph
symbolica.community.graph Class
Graph(*, name: Optional[str] = None, global_data: Optional[GlobalData] = None, codec: Optional[DotCodec] = None, render_config: RenderSettings | None = None, node_store: NodeStore = NodeStore.Vec) An owned topology with arbitrary element data and typed rendering configuration.
Examples
from symbolica.community import graph as linnet
graph = linnet.build(linnet.node("source"), linnet.node("sink"))Constructor
#Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | Optional[ | None | — |
global_data | Optional[ | None | — |
codec | Optional[ | None | — |
render_config | RenderSettings | None | None | — |
node_store | NodeStore | NodeStore.Vec | — |
Member details
name
Property · read-only#name: Optional[str] No description is available for this member.
global_data
Property · read/write## setterglobal_data: GlobalDataNo description is available for this member.
Setter
global_data: GlobalDataParameters
| Name | Type | Default | Description |
|---|---|---|---|
value | GlobalData | — | — |
render_config
Property · read/write## setterrender_config: RenderSettingsNo description is available for this member.
Setter
render_config: RenderSettingsParameters
| Name | Type | Default | Description |
|---|---|---|---|
value | RenderSettings | — | — |
n_nodes
Property · read-only#n_nodes: intNo description is available for this member.
n_edges
Property · read-only#n_edges: intNo description is available for this member.
n_half_edges
Property · read-only#n_half_edges: intNo description is available for this member.
node_store
Property · read-only#__len__
Method#__len__() -> intNo description is available for this member.
to_node_store
Method#node
Method#edge
Method#half_edge
Method#half_edge(index: int) -> HalfEdgeNo description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
index | int | — | — |
nodes
Method#nodes() -> list[Node] No description is available for this member.
edges
Method#edges() -> list[Edge] No description is available for this member.
half_edges
Method#half_edges() -> list[HalfEdge] No description is available for this member.
reorder_nodes
Method#reorder_nodes(order: Sequence[int]) -> None No description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
order | Sequence[ | — | — |
reorder_edges
Method#reorder_edges(order: Sequence[int]) -> None No description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
order | Sequence[ | — | — |
set_orientation
Method#set_orientation(key: int | str, orientation: Orientation) -> None Change an edge's direction and invalidate existing graph-element views.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
key | int | str | — | — |
orientation | Orientation | — | — |
reverse_edge
Method#reverse_edge(key: int | str) -> NoneNo description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
key | int | str | — | — |
map
Method#from_dot
Class method#from_dot_set
Class method#from_dot_file
Class method#to_dot
Method#render
Method#render(*, config: RenderSettings | None = None) -> DiagramView Snapshot a drawing, using native SVG geometry for ordinary graph settings.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
config | RenderSettings | None | None | — |
to_svg
Method#to_svg(*, config: RenderSettings | None = None, browser: Optional[str] = None) -> str No description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
config | RenderSettings | None | None | — |
browser | Optional[ | None | — |
_mime_
Method#_mime_() -> AnyNo description is available for this member.
_repr_mimebundle_
Method#_repr_mimebundle_(include: Optional[Sequence[str]] = None, exclude: Optional[Sequence[str]] = None) -> Any No description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
include | Optional[ | None | — |
exclude | Optional[ | None | — |
full_subgraph
Method#full_subgraph() -> SubgraphNo description is available for this member.
empty_subgraph
Method#empty_subgraph() -> SubgraphNo description is available for this member.
subgraph
Method#subgraph(*, nodes: Sequence[int | str] = ..., edges: Sequence[int | str] = ..., half_edges: Sequence[int] = ...) -> Subgraph No description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
nodes | Sequence[ | runtime default | — |
edges | Sequence[ | runtime default | — |
half_edges | Sequence[ | runtime default | — |
filter
Method#nodes_of
Method#edges_of
Method#half_edges_of
Method#internal_boundary
Method#boundary
Method#external_half_edges
Method#external_half_edges() -> SubgraphReturn dangling/external half-edges as a composable structural selection.
connected_components
Method#count_connected_components
Method#is_connected
Method#cyclomatic_number
Method#is_reachable
Method#is_reachable(source: Node | int | str, target: Node | int | str, *, subgraph: Optional[Subgraph] = None, direction: DirectionBasis = DirectionBasis.Underlying) -> bool Test directed reachability within an optional structural selection.
Both endpoints must belong to the selected subgraph; otherwise this raises ValueError.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source | Node | int | str | — | — |
target | Node | int | str | — | — |
subgraph | Optional[ | None | — |
direction | DirectionBasis | DirectionBasis.Underlying | — |
topological_order
Method#topological_order(*, subgraph: Optional[Subgraph] = None, direction: DirectionBasis = DirectionBasis.Underlying) -> list[Node] Return a deterministic topological order for the selected directed graph.
Explicitly selected zero-crown nodes appear first in ascending graph order.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
subgraph | Optional[ | None | — |
direction | DirectionBasis | DirectionBasis.Underlying | — |
transitive_reduction
Method#transitive_reduction(*, direction: DirectionBasis = DirectionBasis.Underlying) -> Graph Return a new graph with directionally redundant DAG edges removed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
direction | DirectionBasis | DirectionBasis.Underlying | — |
depth_first_traverse
Method#depth_first_traverse(root: int | str, *, subgraph: Optional[Subgraph] = None, include: Optional[int] = None) -> TraversalTree No description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
root | int | str | — | — |
subgraph | Optional[ | None | — |
include | Optional[ | None | — |
breadth_first_traverse
Method#breadth_first_traverse(root: int | str, *, subgraph: Optional[Subgraph] = None, include: Optional[int] = None) -> TraversalTree No description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
root | int | str | — | — |
subgraph | Optional[ | None | — |
include | Optional[ | None | — |
bridges
Method#cycle_basis
Method#all_spanning_forests
Method#all_bonds
Method#all_bonds(*, subgraph: Optional[Subgraph] = None, min_size: Optional[int] = None, max_size: Optional[int] = None) -> list[Subgraph] Enumerate inclusion-minimal cutsets with an inclusive boundary-size range.
Bounds default to [1, unbounded]; min_size=0 is rejected because a bond is non-empty.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
subgraph | Optional[ | None | — |
min_size | Optional[ | None | — |
max_size | Optional[ | None | — |
find_bond
Method#find_bond(*, subgraph: Optional[Subgraph] = None, min_size: Optional[int] = None, max_size: Optional[int] = None) -> Optional[Subgraph] Find one native inclusion-minimal cutset within an inclusive size range.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
subgraph | Optional[ | None | — |
min_size | Optional[ | None | — |
max_size | Optional[ | None | — |
all_cycles
Method#all_cycles(*, max_results: int, subgraph: Optional[Subgraph] = None) -> list[Cycle] Enumerate circuits only when the complete cycle-space candidate count fits the bound.
max_results bounds all non-empty combinations of a cycle basis, not only the combinations that ultimately form circuits.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
max_results | int | — | — |
subgraph | Optional[ | None | — |
tadpoles
Method#all_cuts
Method#all_cuts(source: Sequence[int | str], target: Sequence[int | str]) -> list[CutPartition] Enumerate all native separating partitions between two disjoint, non-empty node groups.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source | Sequence[ | — | — |
target | Sequence[ | — | — |
add_node
Method#add_edge
Method#split_edge
Method#split_edge(at: _HalfEdgeTarget, replacement: EdgeValue, *, name: Optional[str] = None, orientation: Orientation = Orientation.Default) -> tuple[Edge, Edge] Parameters
| Name | Type | Default | Description |
|---|---|---|---|
at | _HalfEdgeTarget | — | — |
replacement | EdgeValue | — | — |
name | Optional[ | None | — |
orientation | Orientation | Orientation.Default | — |
connect
Method#connect(source: _HalfEdgeTarget, sink: _HalfEdgeTarget, replacement: EdgeValue, *, name: Optional[str] = None, orientation: Orientation = Orientation.Default) -> Edge Connect two dangling half-edges; the first becomes the source endpoint.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source | _HalfEdgeTarget | — | — |
sink | _HalfEdgeTarget | — | — |
replacement | EdgeValue | — | — |
name | Optional[ | None | — |
orientation | Orientation | Orientation.Default | — |
concretize
Method#extract
Method#delete
Method#contract
Method#append
Method#append(other: Graph) -> GraphAppend another graph without matching dangling half-edges.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
other | Graph | — | — |
append_mut
Method#append_mut(other: Graph) -> NoneAppend another graph in place without matching dangling half-edges.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
other | Graph | — | — |
join
Method#join_mut
Method#__repr__
Method#__repr__() -> strNo description is available for this member.
__copy__
Method#__copy__() -> GraphNo description is available for this member.
canonize
Method#canonize(*, node_key: _LabelKey = None, edge_key: _LabelKey = None, half_edge_key: _LabelKey = None) -> tuple[Graph, list[int], int, list[int]] Canonical graph, old-to-new vertex map, automorphism-group size, and vertex orbit. Keys receive element payloads; names and drawing metadata do not affect equivalence.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
node_key | _LabelKey | None | — |
edge_key | _LabelKey | None | — |
half_edge_key | _LabelKey | None | — |
is_isomorphic
Method#is_isomorphic(other: Graph, *, node_key: _LabelKey = None, edge_key: _LabelKey = None, half_edge_key: _LabelKey = None) -> bool No description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
other | Graph | — | — |
node_key | _LabelKey | None | — |
edge_key | _LabelKey | None | — |
half_edge_key | _LabelKey | None | — |
canonize_edges
Method#canonize_edges(*, edge_key: _LabelKey = None, half_edge_key: _LabelKey = None) -> None Sort edges canonically while fixing every vertex.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
edge_key | _LabelKey | None | — |
half_edge_key | _LabelKey | None | — |
generate
Static method#generate(external_edges: Sequence[tuple[Expression | int | Float | int | float | str | decimal.Decimal | ComplexFloat | Float | int | float | str | decimal.Decimal | complex | tuple[Float | int | float | str | decimal.Decimal, Float | int | float | str | decimal.Decimal], EdgeSignature]], vertex_signatures: Sequence[Sequence[EdgeSignature]], *, max_vertices: Optional[int] = None, max_loops: Optional[int] = None, max_bridges: Optional[int] = None, allow_self_loops: Optional[bool] = None, allow_zero_flow_edges: Optional[bool] = None, filter_fn: Callable[[Graph, int], bool] | None = None, progress_fn: Callable[[Graph], bool] | None = None) -> list[tuple[Graph, int]] Generate connected labeled graphs and their automorphism-group sizes.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
external_edges | Sequence[ | — | — |
vertex_signatures | Sequence[ | — | — |
max_vertices | Optional[ | None | — |
max_loops | Optional[ | None | — |
max_bridges | Optional[ | None | — |
allow_self_loops | Optional[ | None | — |
allow_zero_flow_edges | Optional[ | None | — |
filter_fn | Callable[ | None | — |
progress_fn | Callable[ | None | — |
to_mermaid
Method#to_mermaid() -> strExport a Mermaid flowchart, with escaped display labels and dangling terminals.
View generated signature source: docs/api/python/linnet-graph.pyi:657