Skip to main content

SimRank-CMP

This is an implementation of SimRank for comparing small, undirected graphs. Notably, it can be used for augmenting pairwise similarities calculated using just the node labels alone, with structural similarity information from the edges.

The algorithm used is exact and non-iterative, and is based on a matrix formulation of SimRank. The main complexity comes from calculating the full eigendecomposition of the adjacency matrices and then doing matrix multiplication. As such, it is not meant to be used on graphs much larger than a few thousand nodes. A derivation can be found here.

For larger graphs and where 1) you don't need exact results, or 2) you don't need pairwise similarities, only similarities for specific node-pairs, there are alternative algorithms.

Installation and Usage

Install with pip install simrank_cmp.

Usage is straightforward:

from simrank_cmp import compute_similarities

updated_similarities = compute_similarities(f_adj, g_adj, initial_similarities, decay=0.8)

initial_similarities should be the pairwise node similarities calculated using some other metric (such as Jaccard). It is important for there to be some signal here in this matrix; SimRank will propagate this information across the graphs.

Examples

In examples/similarity_propagation.py, we visualize the propagation of similarity information across the graph from a single node (the center one in this picture). Darker means more similar.

propagation-img

In examples/match_robustness.py, we are trying to match nodes from two identical graphs. Only 10% of the nodes are labeled, resulting in a ~10% baseline if you were to match nodes at random. The rest of the other nodes are indistinguishable.

By propagating the similarity information from the 10% across the two graphs, we are able to achieve a perfect 100% match of all nodes. We then slowly remove edges from one of the graphs and see that, as expected, accuracy drops until we hit the baseline.

robustness-img

In examples/symmetry.py, we use the algorithm to detect symmetries in the graph. Nodes that have the same color can be swapped without affecting the structure of the graph. This can be useful, for example, during constrained optimization, where symmetry points to redundant solutions that can be pruned.

symmetry-img

Release files for simrank-cmp 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simrank-cmp 1.0.3
File Size Uploaded
simrank_cmp-1.0.3.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simrank-cmp 1.0.3
File Interpreter ABI Platform
simrank_cmp-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / simrank_cmp-1.0.3.tar.gz

Download URL simrank_cmp-1.0.3.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bc65aba4f37cc1a0c7f408d1e75c4f45d4e3e68819995bf3b069bcb71f94f6b1
BLAKE2b-256 checksum
How to use checksums
4b1e6eae2f9b29e30fba6f30be532280636f79bfffe4176bd930dbed3687085f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / simrank_cmp-1.0.3-py3-none-any.whl

Download URL simrank_cmp-1.0.3-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4190b0511b2f06e689d1ea8bfc0b233f9df1cb43227465182ea02a1084815d7e
BLAKE2b-256 checksum
How to use checksums
35b8e80c9e357d09a973ccf69769871e050461ad1d1fb09463e5a6fd5b71aca6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page