4
$\begingroup$

Hi all,

I would like to know if there is a way to compute some measure of similarity between two ordinary graphs with weighted edges. Graphs do not share vertices and can differ in number of vertices and edges.

Any hints, suggestions and thoughts are highly appreciated.

Best, Jozef

$\endgroup$
5
  • 1
    $\begingroup$ A weighted graph is not much different than a real (symmetric if you are not considering digraphs) matrix. A possible candidate is thus using any of the available matrix norms. $\endgroup$ Commented Sep 10, 2010 at 13:43
  • $\begingroup$ @Gjergji - what if the graphs have different numbers of vertices? $\endgroup$ Commented Sep 10, 2010 at 19:36
  • 4
    $\begingroup$ I don't think you can expect to find one good measure of similarity for graphs. Whatever measures you can come up with will depend on which application you have in mind. $\endgroup$ Commented Sep 11, 2010 at 0:22
  • $\begingroup$ @Darsh - add empty vertices. $\endgroup$ Commented Sep 11, 2010 at 1:03
  • $\begingroup$ Treating a weighted graph as a matrix has the problem that you lose permutation invariance (or that you have to explicitly encode permutation invariance into your distance function). $\endgroup$ Commented Feb 25, 2014 at 17:45

6 Answers 6

9
$\begingroup$

If you view the weights as edge lengths then you can view each graph as a metric space, and then use the Gromov-Hausdorff distance between the two metric spaces. This may not be at all suitable for your application but it has been very useful in my own research.

$\endgroup$
2
  • 3
    $\begingroup$ It might not work very well if the weights do not give you a metric space: what about the triangle inequality? $\endgroup$ Commented Sep 11, 2010 at 0:17
  • 2
    $\begingroup$ The weights (assuming they are non-negative) always give you a metric space. The definition of the distance between two vertices is the total weight on the lightest path between them. $\endgroup$ Commented Sep 11, 2010 at 1:13
2
$\begingroup$

If all weights of edges are strictly positive, interpreting them as lengths and considering the Gromov-Hausdorff distance (see http://en.wikipedia.org/wiki/Gromov%E2%80%93Hausdorff_convergence) is perhaps a good candidate. If there are negative weights, replace them by exponentials first.

$\endgroup$
1
$\begingroup$

Comparing two graph structures with the same number of vertices and edges to see if they are equivalent would be the graph isomorphism problem. The graph isomorphism problem is known to be NP in complexity, but it is not known if it is NP-complete nor is it known to be solvable in polynomial time.

Comparing two graph structures with different numbers of edges and vertices would be a slightly bigger problem. Call the graph with the smaller number of vertices $G_1$ and the graph with the larger number of vertices $G_2$. Now you have to search to see if $G_1$ is isomorphic or similar to a subset of $G_2$. Depending on the relative sizes of the graphs, this could take a long time to evaluate.

If you already has a similarity metric defined for two graphs with the same number of vertices, e.g. $d(G_a,G_b)$, where $|V_a|=|V_b|$, then you could proceed as follows.

One way to attack the problem is to take the smaller graph as the template and see if you can overlay it onto the larger graph by taking a subset of the vertices of $G_2$, call it $H_n$ where $n$ can be one of the $\binom{|V_2|}{|V_1|}$ ways of picking a subgraph of $G_2$ with the same number of vertices as $G_1$. $|V_1|$= the number of vertices in $G_1$, and $|V_2|$= the number of vertices in $G_2$ in this case.

One similarity metric to use to compare two graphs with the same number of vertices would be to apply a mapping between vertices between $G_1$ and $G_2$, e.g. {$m: V_{1,a} \to V_{2,b}$}.

Then add up the number of coincident edges: for each edge in $G_1$ which connects $V_{1,i}$ and $V_{1,j}$, find the two corresponding vertices in $G_2$ , $V_{2,m(a)}$ and $V_{2,m(b)} $,and see if there is a corresponding edge is $G_2$ between these corresponding vertices.

$\endgroup$
1
  • 1
    $\begingroup$ Would you kindly share the reference to justify that the graph isomorphism problem is NP? $\endgroup$
    – Supriyo
    Commented Dec 16, 2016 at 4:21
1
$\begingroup$

Determine the modal vertices. Raise the power of the graphs to some power k. Normalize the modal rows. Compare these rows for sufficiently high k.

If these distributions are the same then the graphs are similar.

Following my previous post: In answer to your specific example, Connect the base version of the graph to its changing version at the vertices which are fixed. Then watch the mode Row distribution change as the graph changes using the same matrix power method I described. The mode row is the row containing the vertex, which has the most edges.

What you will get is the drift in mode frequency over time. Similarities follow.

Chris Durand

$\endgroup$
1
$\begingroup$

It might be you find some useful matters in the following article:

A metric on the space of weigthed graphs, Hamed Daneshpajouh, Hamid Reza Daneshpajouh, Farzad Didehvar.

Right now you can find it in arxiv.

$\endgroup$
0
$\begingroup$

Maybe you are interested in Graph Kernels. There is also a python library which implements some of the kernels. I am not sure though if it works for weighted graphs.

$\endgroup$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .