textnets.network.ProjectedTextnet

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

Bases: TextnetBase

One-mode projection of a textnet.

Created by calling Textnet.project() with the desired node_type.

graph

Direct access to the igraph object.

Type:

igraph.Graph

Methods

alpha_cut

Return graph backbone.

ecount

Return the number of edges.

plot

Plot the projected graph.

save_graph

Save the underlying graph.

top_betweenness

Show nodes sorted by betweenness.

top_closeness

Show nodes sorted by closeness.

top_cluster_nodes

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

top_degree

Show nodes sorted by unweighted degree.

top_eigenvector_centrality

Show nodes sorted by eigenvector centrality.

top_ev

Show nodes sorted by eigenvector centrality.

top_harmonic

Show nodes sorted by harmonic centrality.

top_pagerank

Show nodes sorted by PageRank centrality.

top_spanning

Show nodes sorted by textual spanning.

top_strength

Show nodes sorted by weighted degree.

vcount

Return the number of vertices (nodes).

Attributes

betweenness

Weighted betweenness centrality.

closeness

Weighted closeness centrality.

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.

eigenvector_centrality

Weighted eigenvector centrality.

harmonic

Weighted harmonic centrality.

m

Weighted adjacency matrix.

modularity

Return modularity based on graph partition.

node_types

Return list of node types.

nodes

Iterate over nodes.

pagerank

Weighted PageRank centrality.

spanning

Textual spanning measure.

strength

Weighted node degree.

summary

Summary of underlying graph.

alpha_cut(alpha: float) ProjectedTextnet[source]

Return graph backbone.

Parameters:

alpha (float) – Threshold for edge elimination. Must be between 0 and 1. Edges with an alpha value above the specified threshold are removed.

Returns:

New textnet sans pruned edges.

Return type:

ProjectedTextnet

property betweenness: Series

Weighted betweenness centrality.

property closeness: Series

Weighted closeness centrality.

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

Return the number of edges.

property edges: EdgeSeq

Iterate of edges.

property eigenvector_centrality: Series

Weighted eigenvector centrality.

property harmonic: Series

Weighted harmonic centrality.

property m: DataFrame

Weighted adjacency matrix.

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.

property pagerank: Series

Weighted PageRank centrality.

plot(*, alpha: float | None = None, **kwargs) CairoPlot[source]

Plot the projected graph.

Parameters:
  • alpha (float, optional) – Threshold for edge elimination. Must be between 0 and 1. Edges with an alpha value above the specified threshold are removed. This is useful when plotting “hairball” graphs.

  • scale_nodes_by (str, optional) – Name of centrality measure or node attribute to scale nodes by. Possible values: degree, strength, betweenness, closeness, eigenvector_centrality, pagerank or any node attribute (default: None).

  • target (str or file, optional) – File or path that the plot should be saved to (e.g., plot.png).

  • kwargs – Additional arguments to pass to igraph.drawing.plot.

Returns:

The plot can be directly displayed in a Jupyter notebook or saved as an image file.

Return type:

igraph.drawing.Plot

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

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 spanning: Series

Textual spanning measure.

property strength: Series

Weighted node degree.

property summary: str

Summary of underlying graph.

top_betweenness(n=10)

Show nodes sorted by betweenness.

Parameters:

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

Returns:

Ranked nodes.

Return type:

pandas.Series

top_closeness(n=10)

Show nodes sorted by closeness.

Parameters:

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

Returns:

Ranked nodes.

Return type:

pandas.Series

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

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_eigenvector_centrality(n=10)

Show nodes sorted by eigenvector centrality.

Parameters:

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

Returns:

Ranked nodes.

Return type:

pandas.Series

top_ev(n=10)

Show nodes sorted by eigenvector centrality.

Parameters:

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

Returns:

Ranked nodes.

Return type:

pandas.Series

top_harmonic(n=10)

Show nodes sorted by harmonic centrality.

Parameters:

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

Returns:

Ranked nodes.

Return type:

pandas.Series

top_pagerank(n=10)

Show nodes sorted by PageRank centrality.

Parameters:

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

Returns:

Ranked nodes.

Return type:

pandas.Series

top_spanning(n=10)

Show nodes sorted by textual spanning.

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

Return the number of vertices (nodes).