Utilizing igraph Algorithms and Layouts

Using igraph for graph analytics provides powerful and flexible tools for analysis and visualization. Here are some practical examples showcasing its capabilities:

PageRank Computation with igraph

Demonstrating the computation of PageRank using igraph, this example also showcases how to pass a damping parameter to the PageRank function:


edges = pd.read_csv('facebook_combined.txt', sep=' ', names=['src', 'dst'])
g_a = graphistry.edges(edges, 'src', 'dst')
g_b = g_a.layout_igraph('sugiyama', directed=True)  # 'directed' for to_igraph
g_b.compute_igraph('pagerank', params={'damping': 0.85}).plot()  # 'params' for layout

Integrating igraph's community_spinglass Metric

Here, the code computes the igraph community_spinglass metric and integrates the result into the Graphistry nodes:


ig2 = g.to_igraph()
ig2.vs['spinglass'] = ig2.community_spinglass(spins=3).membership
g2 = g.from_igraph(ig2, load_edges=False, node_attributes=[g._node, 'spinglass'])

Multiple igraph Analytics Computation

This example details the computation of multiple igraph analytics and showcases the results derived from the internal DataFrame g._nodes:


df = pd.read_csv('https://raw.githubusercontent.com/graphistry/pygraphistry/master/demos/data/honeypot.csv')
g = graphistry.edges(df, 'attackerIP', 'victimIP')
g2 = (g.materialize_nodes()
      .compute_igraph('pagerank')
      .compute_igraph('betweenness')
      .compute_igraph('harmonic_centrality')
      .compute_igraph('k_core')
      .compute_igraph('clusters'))

g2._nodes.sort_values(by=['pagerank','harmonic_centrality'], ascending=False).head(5)

The examples illustrate how seamlessly Graphistry and igraph can be integrated, capitalizing on the strengths of both platforms for advanced graph analysis.