textnets.network.TextnetBase

class textnets.network.TextnetBase(graph: Graph)[source]

Bases: ABC

Abstract base class for Textnet and ProjectedTextnet.

graph

Direct access to the igraph object.

Type:

igraph.Graph

Methods

ecount

Return the number of edges.

plot

save_graph

Save the underlying graph.

top_cluster_nodes

Show top nodes per cluster, ranked by a chosen metric.

top_degree

Show nodes sorted by unweighted degree.

top_strength

Show nodes sorted by weighted degree.

vcount

Return the number of vertices (nodes).

Attributes

cluster_local_cc

Weighted local clustering coefficient within each cluster's subgraph.

cluster_strength

Weighted node degree within each cluster's subgraph.

clusters

Return graph partition.

degree

Unweighted node degree.

edges

Iterate of edges.

modularity

Return modularity based on graph partition.

node_types

Return list of node types.

nodes

Iterate over nodes.

strength

Weighted node degree.

summary

Summary of underlying graph.

property cluster_local_cc: Series

Weighted local clustering coefficient within each cluster’s subgraph.

property cluster_strength: Series

Weighted node degree within each cluster’s subgraph.

property clusters: VertexClustering

Return graph partition.

The partition is detected by the Leiden algorithm, unless a different partition that was supplied to the setter.

property degree: Series

Unweighted node degree.

ecount() int[source]

Return the number of edges.

property edges: EdgeSeq

Iterate of edges.

property modularity: float

Return modularity based on graph partition.

property node_types: list[NodeType]

Return list of node types.

property nodes: VertexSeq

Iterate over nodes.

save_graph(target: str | bytes | PathLike[Any] | IO, format: str | None = None) None[source]

Save the underlying graph.

Parameters:
  • target (str or path or file) – File or path that the graph should be written to.

  • format ({"dot", "edgelist", "gml", "graphml", "pajek", ...}, optional) – Optionally specify the desired format (otherwise it is inferred from the file suffix).

property strength: Series

Weighted node degree.

property summary: str

Summary of underlying graph.

top_cluster_nodes(n: int = 10, rank_nodes_by: str = 'cluster_strength') DataFrame[source]

Show top nodes per cluster, ranked by a chosen metric.

Parameters:
  • n (int, optional) – How many nodes to show per cluster (default: 10)

  • rank_nodes_by (str, optional) – Metric to rank nodes within each cluster by (default: cluster_strength).

Returns:

Clusters with representative nodes.

Return type:

pandas.DataFrame

top_degree(n=10)

Show nodes sorted by unweighted degree.

Parameters:

n (int, optional) – How many nodes to show (default: 10).

Returns:

Ranked nodes.

Return type:

pandas.Series

top_strength(n=10)

Show nodes sorted by weighted degree.

Parameters:

n (int, optional) – How many nodes to show (default: 10).

Returns:

Ranked nodes.

Return type:

pandas.Series

vcount() int[source]

Return the number of vertices (nodes).