More than 50 years ago the concept of graph homomorphism was introduced [13, 12]. Given two graphs and , a mapping from to is called a homomorphism if every edge of is mapped to an edge of . The graphs and can be either both directed or undirected. Presented in the language of binary relational structures, Lovász proved in that paper  the following fundamental theorem about graph homomorphism: If and are two graphs, then they are isomorphic iff they define the same counting graph homomorphism function, namely, for every , the number of homomorphisms from to is the same as that from to . This number is denoted by . (Formal definitions are in Section 2.)
In  the graph is a 0-1 adjacency matrix; there are no vertex and edge weights. In  Freedman, Lovász and Schrijver define a weighted version of the homomorphism function , where has positive vertex weights and real edge weights. The paper  investigates what graph properties can be expressed as such graph homomorphism functions. They gave a necessary and sufficient condition for this expressibility. This work has been extended to the case with arbitrary vertex and edge weights in a field , and to “edge models”, e.g., [19, 17]. A main technical tool introduced in  is the so-called graph algebras. In  Lovász further investigates these graph algebras and proved precise bounds for their dimensions. These dimensions are a quantitative account of the space of all isomorphisms from to . They are expressed in a theory of labeled graphs. Schrijver  studied the function where is an undirected graph with complex edge weights (but all vertex weights are restricted to 1). He also gave a characterization of a graph property expressible in this form, and proved that implies that for undirected graphs with complex edge weights (but unit vertex weights). Regts in , in addition to finding interesting connections between edge-coloring models and invariants of the orthognal group, also proved multiple theorems in the framework of graph homomophisms (corresponding to “vertex models”) requiring that all (nonempty) sums of vertex weights be nonzero. The possibility that vertex weights may sum to zero has been a difficult point. Our main result is to extend this isomorphism theorem to (directed or undirected) graphs with arbitrary vertex and edge weights. We also determine the precise values of the dimensions of the corresponding graph algebras.
To prove our theorem, we introduce a surprisingly simple and completely elementary argument, which we call the Vamdermonde Argument. All of our results are proved by this one technique.
Two vertices and in an unweighted graph are called twins iff the neighbor sets of and are identical. For weighted graphs, and are called twins iff the edge weights (and for directed graphs also ) for all . In order to identify the isomorphism class of , a natural step is to combine twin vertices. This creates a super vertex with a combined vertex weight (even when originally all vertices are unweighted, i.e., have weight 1). After this “twin reduction” step, our isomorphism theorem can be stated. The following is a simplified form:
Let be a field of characteristic . Let and be (directed or undirected) weighted graphs with arbitrary vertex and edge weights from . Without loss of generality all individual vertex weights are nonzero. Suppose and are twin-free. If for all graphs ,
then the graphs and are isomorphic as weighted graphs, i.e., there is a 1-1 onto map from to that preserves all vertex and edge weights.
we also determine the dimensions of the corresponding graph algebras in terms of the rank of the so-called connection tensors, introduced in. These improve the corresponding theorems in [14, 18, 17] as follows.
From the main theorem (Theorem 2.2) of  we generalize from positive vertex weights and real edge weights to arbitray weights. The main technique in  is algebraic. The proof relies on notions of quantum graphs and structures built from them, and uses idempotent elements in the graph algebras. Similarly, from the isomorphism theorem in  we generalize from unit vertex weights and complex edge weights to arbitray weights. Also we allow directed and undirected weighted graph . Theorem 3 also weakens the condition (1.1) on to simple graphs (i.e., no multiedges or loops). Schrijver’s proof technique is different from that of Lovász , but is also algebraic and built on quantum graphs. He uses a Reynolds operator and the Möbius transform (of a graph). The results of Lovász  and Schrijver  are incomparable. While requiring all vertex weights positive is not unreasonable, it is nonetheless a severe restriction, and has been a technical obstacle to all existing proofs. In Regts’ thesis , multiple theorems were proved with the explicit requirement that all (nonempty) sums of vertex weights be nonzero, which circumvented this issue. In this paper, we allow arbitrary vertex weights with no assumptions. In particular, can have arbitrary complex vertex and edge weights.
However, more than the explicit strengthening of the theorems, we believe the most innovative aspect of this work is that we found a direct elementary argument that bypassed various technical obstacles and unified all previously known versions. We can also show that the only restriction— has characteristic —cannot be removed, and thus our results are the most general extensions on graphs. We give counterexamples for fields of finite characteristic in Section 7.
This line of work has already led to significant applications in the graph limit literature, such as on quasi-random graphs . In  Lovász and B. Szegedy also studied these graph algebras where “contractors” and “connectors” are used. In our treatment these “contractors” and “connectors” can also be constructed with simple graphs.
In terms of applications to complexity theory, there has been a series of significant complexity dichotomy theorems on counting graph homomorphimsms which show that the function is either P-time computable or #P-hard, depending on [7, 8, 2, 11, 20, 10, 4, 6, 3]. These theorems differ in the scope of what types of are allowed, from 0-1 valued to complex valued, from undirected to directed. In all these theorems a P-time tractability condition on is given, such that if satisfies the condition then is P-time computable, otherwise is #P-hard. In the latter case, the theorem asserts that there is a P-time reduction from a canonical #P-hard problem to . However, various pinning lemmas are proved nonconstructively; for undirected -weighted graphs  it was unknown how to make this constructive. Consequently, there was no known algorithm to produce a #P-hardness reduction from . Because the proof in this paper is constructive, they can be used to make all these dichotomy theorems effective, i.e., we can obtain an algorithm such that for any either outputs a P-time algorithm solving or a P-time reduction from a canonical #P-hard problem to .
We first recap the notion of weighted graph homomorphisms , but state it for an arbitrary field . We denote for integer . In particular, . By covention , and in , , etc. Often we discuss both directed and undirected graphs together.
An (-)weighted graph is a finite (di)graph with a weight associated with each vertex (0-weighted vertices can be deleted) and a weight associated with each edge (or loop if ). For undirected graphs, . It is convenient to assume that is a complete graph with a loop at all nodes by adding all missing edges and loops with weight . Then is described by an integer (
can be the empty graph), a nowhere zero vectorand a matrix . An isomorphism from to is a 1-1 onto map from to that preserves vertex and edge weights.
According to , let be an unweighted graph (with possible multiple edges, but no loops) and a weighted graph given by , we define
The unweighted case is when all node-weights are 1 and all edge-weights are 0-1 in , and is the number of homomorphisms from into .
A -labeled graph () is a finite graph in which nodes are labeled by (the graph can have any number of unlabeled nodes). Two -labeled graphs are isomorphic if there is a label-preserving isomorphism between them. denotes the -labeled graph on nodes with no edges. In particular, is the empty graph with no nodes and no edges. The product of two -labeled graphs and is defined as follows: take their disjoint union, and then identify nodes with the same label. Hence for two -labeled graphs, (disjoint union). Clearly, the graph product is associative and commutative with the identity , so the set of all (isomorphism classes) of -labeled graphs togegher with the product operation forms a commutative monoid which we denote by . We denote by the submonoid of simple graphs in ; these are graphs with no loops, at most one edge between any two vertices and , and no edge between labeled vertices. A directed labeled graph is simple if its underlying undirected one is simple; in particluar, for any and , we require that if is an edge then is not an edge. Clearly, is closed under the product operation (for both directed and undirected types).
Fix a weighted graph . For any -labeled graph and mapping , let
where means that if is labeled by then , and , , so is the product of vertex weights of not in . Then
When , we only have the empty map with the domain . Then for every . The functions where and satisfy
Given a directed or undirected -weighted graph , we call two vertices twins if for every vertex , and . Note that the vertex weights do not participate in this definition. If has no twins, we call it twin-free.
The twin relation partitions into nonempty equivalence classes, where . We can define a twin contraction graph , having as vertices, with vertex weight for , and edge weight from to to be for some arbitrary and . After that, we remove all vertices in with zero vertex weights together with all incident edges (still called ). This defines a twin-free . Clearly, for all .
We denote by the set of -weighted graph isomorphisms from to and by the group of (-weighted) graph automorphisms of .
It is obvious that for directed (or undirected) -weighted graphs and , and the maps and such that for some isomorphism of to , we have for every .
3 Our results
Theorem 1 is a direct consequence of the case of the following Main Theorem. Let be a field of characteristic . Let be (directed or undirected) -weighted graphs such that is twin-free and . Suppose and where . If for every then there exists an isomorphism of -weighted graphs from to such that (a fortiori, is twin-free and ).
In Section 8 we will give our results about the space of such isomorphisms, expressed in terms of the dimensions of the corresponding graph algebras. However, all results stated in this section will be proved in Section 5.
In Corollaries 3 to 3, . The following two corollaries extend Lovász’s theorems in  from real edge weight and positive vertex weight. Furthermore it holds for both directed and undirected graphs, and the condition on is weakened to assume for simple graphs only. The fact that the theorem holds under the condition for loopless graphs is important in making the complexity dichotomies effective in the sense defined in Section 1.
Let be twin-free (directed or undirected) -weighted graphs. Let and , where . If for every , then there exists an isomorphism such that .
Let be (directed or undirected) -weighted twin-free graphs. If for every simple graph , then and are isomorphic as -weighted graphs.
For edge weighted graphs with unit vertex weight, the requirement of twin-freeness can be dropped. The following two corollaries directly generalize Schrijver’s theorem in . Corollary 3 is a restatement of Corollary 3 using the terminology in . Here we strengthen his theorem by requiring the condition for only simple graphs . Also our result holds for generalizing from , and for directed as well undirected graphs. Let be (directed or undirected) -edge weighted graphs. If for every simple graph , then the -weighted graphs and are isomorphic.
Let and . Then for every simple graph iff and there is a permutation matrix such that .
Our proof of Theorem 3 will show that for any given , there is an explicitly constructed finite family of graphs in such that the condition for all can be replaced with for all in this family, thus explicitly finitary. Moreover, this provides an explicit set of “witnesses” that can be used to make various complexity dichotomy theorems for graph homomorphism effective, in particular, making the pinning steps in  computable, which was an open problem.
4 Technical statements
We start with an exceedingly simple lemma, based on which all of our results will be derived. We will call this lemma and its corollary the Vamdermonde Argument. Let , and for . Suppose
Then for any function , we have .
Remark: The statement is vacuously true if , since an empty sum is 0. If (4.1) is true for , then the same conclusion holds for any function satisfying .
We may assume . We partition into such that belong to the same iff . Then (4.1) is a Vandermonde system of rank with a solution . Thus for all . It follows that for any function . We also note that if (4.1) is true for , then the same proof works except when some . In that case, we can separate out the term for the unique that contains this , and we get a Vandermonde system of rank on the other terms , which must be all zero. ∎
By iteratively applying Lemma 4 we get the following Corollary.
Let be a finite (index) set, , and for all . Further, let be the partition of into equivalence classes, where are equivalent iff for all . If for all and , then for every .
In this paper we prove for directed graphs; the proof also work for undirected graphs, with some simplifications.
5 Proof of Main Theorem
Without loss of generality, we assume the vertex sets , and we denote by , , , and the vertex and edge weights in and , correspondingly.
Let be (directed or undirected) -weighted graphs such that is twin-free and . Suppose and where . If for every and for every , then there exists an isomorphism of -weighted graphs from to such that (a fortiori, is twin-free and ).
If , then (so both are the empty graphs). Since exist, they can only be the empty maps, it must be the case that . In this case we let be the empty map.
Now we may assume . Then we can take so that . Hence also as the map has a nonempty domain .
For each , we define a directed graph as follows.
The vertex set is , with each labeled . For each , there is a directed edge from to if , a directed edge from to if and no edge between and if . This defines the edge set .
Clearly, each .
We now define a specific set of , given and . We can partition where each and . For every , since , there exists a nonempty subset such that and the restriction takes a constant value. We fix such a for each . Then for some function we can write the restriction of to as for all . Next, for each , since , for every , we can fix disjoint subsets and , with and . Then we let the tuple be defined as follows: , and all other entries are . This way every possible choice of with defines a tuple of sets with disjoint for , which in turn defines the tuple by the previous rule. Let be the set of all such tuples for every possible choice of with .
Then for every with is expressed by
This holds for every choice of with . In (5.1) the summation on comes from assigning to on the LHS, and to on the RHS.
Because is twin-free the -tuples for are pairwise distinct. In (5.1) the sum in the LHS has terms, while the sum in the RHS has terms. Transferring RHS to LHS we get at most terms, and we then apply Corollary 4. By the pairwise distinctness of the -tuples for , we see that each term from the LHS of (5.1) must be canceled by some terms from the RHS. Again by the pairwise distinctness, there exist pairwise disjoint subsets for such that for all and for every , and also for every . Since every by the definition of an -weighted graph, we see that so that for . However, so this can only occur if , each and . Then we can write the singleton sets for , where is bijective. To sum up,
Note that, since (5.2) holds for all , if we observe the second entry of each pair, we have (as well as from the first entry of each pair).
If for some we have , then
Since is twin-free we conclude that . Thus the map is injective and therefore bijective. However, is also bijective, it follows from (5.2) that the tuples for are pairwise distinct, which means that is twin-free as well.
Next we show for all . If for all , we have , then we are done. Otherwise, take any such that is a proper subset of and we take any . Observe that for all , in particular, for each .
For each and , let be the tuple obtained from by reassigning (changing its th entry) from to and let be the set of all such .
Then for every with is expressed as (recall that we have proved that )
for every where . Since , and the tuples for are pairwise distinct, by Corollary 4, we get . But all so for . Using for every with , we similarly conclude that for . On the other hand by (5.2), and for . It follows that and for . However is a bijection and, as shown before, is twin-free, this implies that . Recall that . This proves that on , also takes the constant value . Thus for all .
Next we prove that for all , i.e., preserves the edge weights.
For each and , we define a directed graph as follows:
The vertex set has vertices , with each labeled . There is a directed edge from to and, for each , there is a directed edge from to if , from to if , and no edge between and if ; there is a directed edge from to if , from to if , and no edge between and if . This defines the edge set .
Clearly, each .
Let . By the definition of , every corresponds to disjoint subsets , and also , for , such that , where , and , , , , and all other entries are . Moreover, the above correspondence between and the tuples is bijective.
Then for every with is expressed as
so this holds for every where . Transferring RHS to LHS and using (5.2) we get
for every , where . Since the tuples for are pairwise distinct, the tuples for are also pairwise distinct. Then by Corollary 4, . But all so
This means that the bijection preserves the edge weights in addition to the vertex weights by (5.2). Hence is an isomorophism of -weighted graphs from to .
Proof of Theorem 3.
Consider an arbitrary and let be any -labeled graph. Let be the graph obtained by unlabeling the labels not in from (if , then ). Clearly, so