A metric on the space of weighted graphs

A metric on the space of weighted graphs


In this paper we offer a metric similar to graph edit distance which measures the distance between two (possibly infinite)weighted graphs with finite norm (we define the norm of a graph as the sum of absolute values of its edges). The main result is the completeness of the space. Some other analytical properties of this space are also investigated.


Many objects can be demonstrated with weighted graphs. In any collection of objects of similar nature a way to quantify the difference between objects may be desired (For instance if we were to select the most similar objects to a given object from a database). In the theoretical side one common way is to develop a metric on the space of objects in demand. One way to build a metric, is to define some operations that transform the members of the space to one another, and assign a cost to each operation then define the distance between two objects to be the minimum cost that must be payed to transform the first object to the second via a sequence of the defined operations. Such metrics sometimes are referred to as “Edit distance”. Two examples of them are the “Levenshtein edit distance” [1] on strings and “Graph edit distance” [2] on the space of finite graphs. This paper extends the Graph edit distance to the space of “countable weighted graphs with finite norm” and investigates some topological properties of the space.

2Priliminaries and intuitive examples

In this chapter, we introduce the concepts intuitively. The main question here is “given two graphs, how much they differ?”. Based on this question we could define different distances, we choose here “Graph edit distance” and we generalize it to infinite graphs.

Given two graphs, it is possible to transform one to the other by addition and deletion of some vertices and edges. The minimum number of edge addition and deletions in such a process is the distance between the two graphs and is denoted by . In the above example , because we added an edge and deleted one. It is clear that if two graphs differ only in isolated vertices, then by this definition their distance is zero.

3Developing the metric mathematically

We first define the distance between two labeled graphs and then define unlabeled graphs as the equivalence classes of labeled graphs. The main result in this chapter is to show that the introduced distance provides us a metric space.

We use standard graphs in constructing unlabeled weighted graphs, it has several benefits, in particular with an infinite number of isolated vertices we don’t need to delete or add a vertex.

When no confusion can arise we use the term “graph” instead of “labeled graph” and “unlabeled graph”. A graph with all edge weights equal to , simply is denoted by . We sometimes use common graph theory notions here, converting them to match our definitions is not difficult, for example “to delete an edge” means “to change its weight to zero”.



proof. Let

If then , otherwise we can define

Clearly . Choose and such that . For , , and two cases are possible , which implies

or , in this case because otherwise , and hence which is a contradiction. Thus

therefore in each case, and consequently .

In the following lemma which is known as Konig infinity lemma, please forget our notion of a graph, just take it as in ordinary graph theory texts.

proof. Assume that and . The above lemma implies that . Denote by and the sets of non-isolated vertices of and , and by the set of all pairs in which is an isomorphism between nonzero parts of and

Since and , are finite, is nonempty and finite. Define a graph with vertex set and edge set . Consider . Let be the restriction of to , it is easily seen that and is a neighbor of so each vertex in has a neighbour in . Then according to Konig infinity lemma, there is an infinite sequence of vertices such that for each , the vertex is adjacent to the vertex , i.e . We put . is an isomorphism between nonzero parts of and . Since both and have a countable number of isolated vertices, can be extended to an isomorphism between and .

4Completeness of

In this chapter and the next one we try to find some topological properties of . The main result in this chapter is the completeness of .

proof. : Let , since

the elements exist such that , therefore . is evident It follows from the inequality

proof. Suppose , we shall define the graphs and by means of the following equations

we simply observe that is a standard graph and and so , therefore and accordingly .

proof. The transitive and reflexive properties are consequences of the similar properties in . The proof of the antisymmetric property: If this property fails, then holds for some , implying , which is impossible.

proof. 1) For each and we have

so . 2) Choose and such that , clearly

which in combination with (1) gives the result.

If is an increasing sequence in , then there exists an increasing sequence such that for every , . It is enough to select from then construct other terms inductively.

proof. We take and select satisfying and choose such that

we also set . Since A is finite, we can select and in such a way that

Now for

proof. Suppose that is an increasing bounded sequence in . We define the graph as follows

The sequence is ultimately constant, so the limit exists. It is easily seen that ⃒

Given the fact that، for any , we have

therefore . Now, suppose is an increasing bounded sequence in . Corresponding to this sequence, there is an increasing sequence such that . The convergence of is a result of the convergence of .

proof. It is clear that . To show the inverse, we take and . Let , , and and define the graph as follows

according to the assumption, and (or and ). Using these relations one can easily show that

proof. Let be the sequence related to graph in definition 10, and relate a similar sequence to . We set and . Applying the preceding lemma times, we obtain

Since the sequences and are convergent to , and consequently

proof. Set it is easily seen that

and B is a closed subset and consequently a complete subset of . According to the theorem 8, is an onto isometry, so is also complete.

By a correspondance between two graphs we mean a choice of two members and .

proof. Suppose that is a Cauchy sequence. Since , so the sequence is also Cauchy. Therefore according to the preceding lemma, the sequence is convergent to a jointless graph . Set and let . Suppose is obtained from by rounding the weight of each edge to the closest number in (if the weight of an edge has the least difference with two numbers in A, we choose one of them arbitrarily). Set , we claim that . In fact, it is easily seen that , which proves the claim. Therefore, it is enough to show ’s convergence instead of ’s. First let us show that for all there exists a natural number such that

To prove that we set and . Since does not have a nonzero limit point and is finite, so . The relation shows that is a Cauchy sequence so there is a such that for every . Now, if for one , in every correspondence between and we get an edge which has two different weights in the two graphs, one of which from , and the other from , and hence , which is a contradiction. Choose a strictly increasing sequence such that for each , and satisfy the equation (Equation 1). It is evident that for each , . Then, since , so the sequence is bounded and consequently converges to a graph . We have


(Equation 2) and (Equation 3) conclude that

Therefore , so has a convergent subsequence and consequently, it is convergent itself.

5Examining the space for some other common topological properties

Besides the completeness of there are some other important properties of the space, we discuss a few of them here. Note that, in this chapter by a finite graph we mean one that has only finitely many non-isolated vertices. Also in a metric space we denote the ball with center and radius by .

proof. The set of all finite graphs with rational edge weights is a dense subset of . By a finite graph we mean one that has only finitely many non-isolated vertices. Also in a metric space we denote the ball with center and radius by .

proof. The set of all finite graphs with rational edge weights is a dense subset of .

proof. Suppose the contrary, so there is an open neighbourhood such that is compact. Consider the sequence in which is the jointless graph with edges of weight . This sequence must have a convergent subsequence. The tiny edges of this subsequence say that it converges to . On the other hand the norm of its members are always equal to implying that the norm of the limit graph must be , which is a contradiction.

proof. Take the standard graph . The function , is a path between 0 and , so every point is connected to 0 via a path.

proof. The onto function from to is continuous and hence takes path connected to path connected.

proof. First we show that every ball in is path connected. Let , and . Choose a finite graph from (finite graphs are dense in ). is convex and the graphs and have infinitely many isolated vertices in common, so we can define the function , which is a path between and . So every member of is connected to via a path, therefore the ball is path connected. Now according to the facts that for each we have (which is not difficult to prove) and that the function from to is continuous, every ball in is path connected and so is locally path connected.

We are grateful to professor Sayyad Ebadollah Mahmoodian, for his valuable advices and comments during this work. We also thank all friends that directly and indirectly gave us hands in the preparation of this paper.


  1. Binary codes capable of correcting deletions, insertions, and reversals by: Vladimir I Levenshtein Soviet Physics Doklady, Vol. 10, No. 8. (1966), pp. 707-710.
  2. J. Balogh R. Martin, Edit distance and its computation, Electronic Journal of Combinatorics, 15(1), Research Paper 20, 27 pp
Comments 0
Request Comment
You are adding the first comment!
How to quickly get a good reply:
  • Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
  • Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
  • Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters
Add comment
Loading ...
This is a comment super asjknd jkasnjk adsnkj
The feedback must be of minumum 40 characters
The feedback must be of minumum 40 characters

You are asking your first question!
How to quickly get a good answer:
  • Keep your question short and to the point
  • Check for grammar or spelling errors.
  • Phrase it like a question
Test description