Figures
Abstract
Axiomatizing centrality measures often requires proving that certain properties do not hold by exhibiting a counterexample (i.e., a graph for which a given centrality measure does not satisfy a specified property). In the context of geometric centralities, constructing such counterexamples requires building a graph with prescribed distance counts, as encoded in its distance-count matrix (DCM). We prove that deciding whether a matrix is the distance-count matrix of an undirected graph is strongly NP-complete. This negative result implies that a brute-force approach to constructing such counterexamples is out of the question. We complement this negative result with some positive findings: while recognizing DCM matrices is strongly NP-hard, the construction of DCM matrices is algorithmically well-behaved under some natural graph operations (which we call DCM-stable): that is, for many important graph operations ⊗, the DCM of can be computed efficiently from those of
and
, without having to reconstruct the graphs themselves. This observation shows that, although the inverse problem is intractable in general, distance-count matrices admit a rich and tractable compositional theory on structured graph classes generated by DCM-stable operations.
Citation: Boldi P, Prezioso C, Furia F, Stewart I (2026) Recognizing distance-count matrices. PLoS One 21(7): e0352427. https://doi.org/10.1371/journal.pone.0352427
Editor: Tiago Pereira, Universidade de Sao Paulo, BRAZIL
Received: February 25, 2026; Accepted: June 10, 2026; Published: July 8, 2026
Copyright: © 2026 Boldi et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Data Availability: No datasets were generated or analyzed during the current study. Therefore, PLOS ONE policies on sharing data are not applicable to this article.
Funding: This work was supported in part by project SERICS (PE00000014) under the NRRP MUR program funded by the EU - NGEU. Views and opinions expressed are those of the authors, and do not necessarily reflect those of the European Union or the Italian MUR. Neither the European Union nor the Italian MUR can be held responsible for them.
Competing interests: The authors have declared that no competing interests exist.
1 Introduction
The distance-count matrix (DCM) of a graph is a matrix whose rows correspond to the vertices, and where the k-th column for vertex v contains the number of vertices whose (shortest-path) distance to v is equal to k. The DCM contains a lot of information about the graph itself, and it is a natural object to study, especially in the context of social network analysis: a large family of centrality measures, called geometric centralities [1], are those that can be expressed as a function of the DCM of a graph. This family includes degree centrality, closeness [2], Lin centrality [3], harmonic centrality [1], and many others. As an example, the harmonic centrality of a node i in the graph is defined as follows:
where is the set of vertices of
, and
is the length of a shortest path from j to i in
; we understand
to be 0 if
is infinite (i.e., if there is no path from j to i). The intuition, here, is that a node is more central if it is closer to all other nodes in the graph; more central nodes have smaller distances, hence larger inverse-distance summation. To compute the harmonic centrality of a node i, we need to know how many nodes are at distance 1 to i, how many are at distance 2, and so on: this information is precisely encoded in the DCM of the graph. More precisely, if
is the number of nodes at distance t to i in
, and
, then we can rewrite the harmonic centrality of i as
The subfamily of linear geometric centralities alone was also studied in the pioneering works in Kishi et al. [4,5], and more recently in [6,7]. The DCM implicitly contains other information, such as the eccentricity of all vertices (and their distribution), the diameter and effective diameter [8] of the graph, the distance distribution [9], and the graph Wiener index [10,11]. The problem of computing or approximating the DCM is therefore extremely important in practice and challenging, especially for large graphs [12]. While building the DCM of a given graph is relatively easy, the main result we prove is that deciding whether a matrix is a DCM of an undirected graph is strongly NP-complete. This negative result is especially relevant when trying to build counterexamples to specific properties of geometric centralities: in such a situation, it may be possible to find a candidate DCM that works as a counterexample, but then the problem is to determine whether that candidate matrix is the actual DCM of some graph. Our result implies that this road is basically impossible, so we must explore a different technique for finding a counterexample.
We contrast this negative result with some positive observations. Even if recognizing whether a matrix is a DCM is extremely difficult, the construction of DCM matrices is algorithmically well-behaved under some natural graph operations. Let us call a graph operation ⊗ DCM-stable if the DCM of can be computed efficiently from those of
and
, without having to reconstruct the graphs themselves: if this property holds, we call ⊗ DCM-stable.
We shall be able to prove that many common graph operations are DCM-stable. This observation shows that, although the inverse problem is intractable in general, distance-count matrices admit a rich and tractable compositional theory on structured graph classes generated by DCM-stable operations. Furthermore, DCM-stability has a concrete algorithmic payoff: one can get the DCM of exponentially large graphs (e.g., powers with respect to stable operations) without ever materializing the full graph. In other words, DCM matrices turn out to have a rich algebraic structure that mirrors the algebraic operations between the graphs they represent.
2 Related work
The rows of the distance-count matrices have been considered in the graph-theoretical literature under the name of “distance degree sequences” (or dds) [13, Chapter 5], and were studied in some special scenarios (e.g., to determine which graphs have vertices with pairwise distinct dds, and which have the same dds for all vertices [14]), but not in the general case.
Determining whether a given sequence of integers is a graphical degree sequence, that is, the degree sequence of an undirected graph, is a well-known problem in graph theory: among the first results about this problem are the celebrated Erdős-Gallai theorem [15], characterizing graphical degree sequences, and the Havel-Hakimi algorithm [16,17], which gives a constructive way to check in polynomial time whether a sequence is a graphical degree sequence, and provides, in the positive case, a possible realization of the sequence as a graph. Later, the problem was also studied in the context of directed graphs [18], where instead of the degree sequence one considers the in-degree and out-degree sequences.
Another quite natural generalization of the problem is to take a list of pairs of integers and determine whether this is a second-order degree sequence of a simple undirected graph. Such a sequence contains, for every vertex i, the number of vertices
at distance 1 (i.e., its degree) and the number of vertices
at distance 2. This version of the problem, however, is strongly NP-complete [19]. In this paper, we consider an even more general version of the problem, where our input is the whole distance-count matrix of a graph.
The intuition that recognizing DCMs may itself be NP-complete comes from the fact that the first two columns of the DCM of a graph are precisely its second-order degree sequence: in the light of [19] we can expect that the problem of recognizing DCMs is at least as hard. But the DCM contains much more information than the second-order degree sequence: it contains the number of vertices at distance k for every k, and therefore it is a complete description of the distances in the graph. So, we may think that this additional knowledge could make the problem easier. Formally, there is no easy polynomial reduction between the two problems, in either direction.
3 Notation
A graph is given [20] by a finite set of nodes
and a set of arcs
; we assume that our graphs have no self loops, i.e.,
for all
. (For this and similar notations, the subscript
is dropped whenever it is clear from the context.) Without loss of generality we let
where n is the number of nodes. We write
to mean that
and
; we say that x is a predecessor of y, that y is a successor of x, and that x (y, respectively) is the tail (head, respectively) of the arc
. A graph is undirected iff
implies
. For undirected graphs, we write simply
, and say that x and y are adjacent.
A path of length k from x to y is a sequence of nodes such that x = x0,
and
for all
; the arcs
are said to belong to the path. We say that a path is simple if it does not contain any node twice.
The (shortest path) distance from x to y in , denoted by
, is the length of a shortest path from x to y, or ∞ if no path from x to y exists. A (strongly) connected graph is one where the distance between every pair of nodes is finite (the adverb “strongly” is usually omitted for undirected graphs). See, for instance, the graph of Fig 1.
In a connected undirected graph, the distance function is a metric, that is, for all
(1)
and equality holds if and only if x = y; (2) d(x,y)=d(y,x) (symmetry); (3)
(triangle inequality). In a strongly connected directed graph symmetry does not hold in general, while the other two properties remain true. (Strong) connectivity is needed here for otherwise infinite distances get in the way, making the relation with metric spaces improper.
The (in)-eccentricity of a node x in is defined as the maximum finite d(y,x) as y ranges over all nodes of
. The maximum eccentricity of all nodes in
is called the diameter of
, and it is denoted by
.
4 Distance-count matrices (DCM)
We start by giving some definitions:
Definition 4.1 (DCM and CDCM). Given a graph , a node x and a natural number k, define
The distance-count matrix (DCM) of is the matrix
such that
, i.e., the number of nodes at distance exactly k to i. The cumulative distance-count matrix (CDCM) of
is the matrix
such that
, i.e., the number of nodes at distance at most k to i. (It is convenient to assume that vector and matrix elements are indexed starting from zero.)
In Fig 2 we show an example of DCM and CDCM (for the directed graph of Fig 1). Observe that for all k,
where we conveniently assume that . The definitions describe the set of nodes that are found by moving further and further away from a node. We can think of it as a circular wave that starts from node x: as k increases we find nodes that are more and more distant from x. Eventually, after k has reached the eccentricity of x, no more nodes are found. We can examine either the set (or count) of nodes at any given distance from the centre (the functions N and n), or (equivalently) the cumulative set or count of nodes found along the way (the functions M and m). Also observe that we are computing distances to x, not from x: this fact is a matter of convention, all our results hold also if we consider the distance from x to y instead of the distance from y to x; in the undirected case, the two are the same.
4.1 DCMs and linear centralities
A (graph) centrality [21] is a function associating with each graph
a map
such that for any two graphs
, if
is an isomorphism then
for all .
Centralities that depend essentially only on the rows of the DCM are called geometric [7,22]; within this class, particularly relevant are the so-called linear geometric centralities.
Let : we view a as an infinite vector of real numbers. If
is an
matrix, we write
as a shortcut for
where stands for the vector of the first n entries of a.
Definition 4.2 (Linear (geometric) centrality). Given (the coefficient vector), the centrality
is defined by
A centrality is strictly linear (geometric) if it is for some
. A centrality is linear (geometric) if it is equivalent to (i.e., it produces the same node ranking as) a strictly linear (geometric) centrality.
One special instance of (strictly) linear centralities are the so-called exponential-decay centralities [23]:
Definition 4.3 (Exponential-decay centrality). Given , the exponential-decay centrality of a node
is defined by
where a is obtained for every k > 0 as , and a0 = 0.
Observe that , seen as a function of
, is a polynomial whose coefficients are those in the i-th row of
(lowest-degree first). We use
to denote such a polynomial. More explicitly,
The degree of is at most
4.2 Graphical sequences for undirected graphs
A good reference about distances in graphs is [24]: this book includes material on DCMs under different terminology for the undirected case. The distance degree sequence (or dds) of node v of an undirected graph (see [24, Section 9.2]) is the vector
where is the number of nodes w such that d(v,w) = i, and e(v) is the eccentricity of v, which is the maximum value of d(v,w) for
. Thus, dds(v) is row v of the DCM, truncated to remove the final zeros.
The distance degree sequence (or dds) of the graph
is the list of all dds’s of its nodes, listed including multiplicity (see [24], Sect 9.2). This is essentially the DCM with zero entries removed.
Also of interest is the degree sequence of an undirected graph (see [24, Section 9.2]), which is the list of degrees of nodes arranged in nonincreasing order. Up to permutation of the nodes, this is column 1 of the DCM of
.
Not all sequences of positive integers can be a degree sequence. A graphical degree sequence is a degree sequence that can be realised by an undirected graph. A complete characterization of graphical degree sequences for undirected graphs is given by the Erdős-Gallai theorem:
Theorem 4.4 ([15]). Consider a sequence of p positive integers. This sequence is a graphical degree sequence if and only if its sum is even and for every
The Havel-Hakimi algorithm [16,17] provides a constructive way to check in polynomial time if a sequence is a graphical degree sequence. The algorithm is essentially described by the following [24, Theorem 9.1]:
Theorem 4.5. The sequence with
for positive integers
is a graphical degree sequence if and only if
when re-ordered in nonincreasing order, is a graphical degree sequence.
The Havel-Hakimi algorithm applies Theorem 4.5 inductively: if the process stops at the empty sequence, the original sequence is a graphical degree sequence; if any entry becomes negative before this happens, it is not a graphical degree sequence.
As explained above, column 1 of the DCM of an undirected graph is always a graphical degree sequence. This fact is more general: all columns of a DCM are graphical degree sequences; more precisely, column k of the DCM of an undirected graph is the degree sequence of the graph
having the same vertices as
and with an edge
iff
.
4.3 Graphical in-degree sequences
Mutatis mutandis, we can define the in-degree sequence of a directed graph as the list of in-degrees of nodes arranged in non-increasing order. Up to permutation of the nodes, this is column 1 of the DCM of
. We can ask whether the algorithm described in Theorem 4.5 can be adapted to in-degree sequences. In fact, the result for directed graphs is much simpler:
Theorem 4.6. The sequence with
for natural numbers
is always the in-degree sequence of a directed graph.
Proof. Just use and for every
, add
edges, whose head is node i and whose tails are
distinct but arbitrarily chosen elements of
. □
A more sophisticated question is whether a given sequence of pairs is the sequence of in- and out-degrees of a graph: the Kleitman–Wang Algorithm [18] extends the Havel-Hakimi Algorithm for this case.
4.4 Some basic properties of (C)DCMs
In this brief section we collect some observations about (C)DCMs. Let us start with some trivial ones.
Proposition 4.7. In any graph with n nodes, for any node i of
, and for any
:
- (a)
.
- (b)
.
- (c)
and
where
is the in-degree (number of predecessors) of i.
- (d)
.
- (e)
.
- (f)
.
- (g)
.
- (h) If M is a DCM (resp. CDCM), so is any matrix obtained by permuting the rows of M.
- (i)
if and only if d(j,i) is finite for all nodes j; in particular, this is always true if
is strongly connected.
Observe that the (C)DCM of a graph is uniquely defined only up to row permutation, but by (h) we can use lexicographic order to define a unique (C)DCM of a graph, that we shall call the canonical (C)DCM of .
We can extend the function to subsets: for
, define the p-neighbourhood of
to be
Clearly
Proposition 4.8. For any graph and node i:
- (a) If
then
for
.
- (b) If
is strongly connected and
then
and
for all
.
Proof. (a) If then case (d) of Proposition 4.7 implies that
. We use induction on r. The result holds for r = 1. For the induction step:
(b) This follows from (a), since for any i by connectedness of
.
Corollary 4.9. For any graph and node i the sequence
for
(which is the i-th row of the CDCM) is monotonic strictly increasing until it reaches a certain value k, at which point all subsequent entries equal k. The value k is exactly the number of nodes j such that d(j,i) is finite. If
is strongly connected, k = n.
Definition 4.10 (Good sequence). For a given n, a sequence of positive integers is good if a0 = 1 and there exists j and
such that
and
for all
. If further k = n, we say that the sequence is very good.
Corollary 4.9 states that every row of a CDCM is good. If furthermore the graph is strongly connected, its rows are very good. We observe:
Theorem 4.11. Every good sequence occurs in the CDCM of some graph (in particular, some undirected graph).
Proof. Let the good sequence be , and define
for all i > 0, and b0 = 1. Define
to be a tree with root node 0. Node 0 is connected to nodes
. One of those nodes connects to nodes
, and so on inductively. Then the 0-th row of
is
, so the 0-th row of
is
. See Fig 3. □
We end this section with some necessary conditions for a matrix to be a CDCM, in terms of inequalities. We already know:
Theorem 4.12. For the CDCM of a strongly connected graph:
- (a) The column 0 entry in any row is 1.
- (b) The column 1 entry in row i is
. That is, the CDCM (hence also DCM) tells us the in-degree of node i.
- (c) Each row is very good.
We now prove two further inequalities.
Theorem 4.13. Let be the CDCM of a graph
. Then for any
, with
, there exist distinct
such that:
and
for all .
Proof. Let be the predecessors of i in
. To prove (3), observe that since
, we have
. Therefore
. This holds for all k such that
, and this proves (3). To prove (4), observe that by (2),
Therefore
which is (4). □
That is, the vector of entries of row i after the first is bounded below, termwise, by the maximum of other distinct rows shifted one place to the right. It is bounded above, termwise, by the sum of the same
distinct rows, again shifted one place to the right. Of course, we do not know which
rows to choose, but one such set of rows must exist. If no such set exists, the matrix under consideration cannot be a CDCM.
5 NP-Completeness of (C)DCM recognizability
In this section, we show that the problem of deciding whether a matrix is a (C)DCM of an undirected graph is (strongly) NP-complete. We use a reduction from a special instance of the three-partition problem (TPP) [25], which is a well-known strongly NP-complete problem.
As already discussed, Erdős and Miklós proved in [19] (in our terminology) that deciding whether two sequences of integers are the columns of indices 1 and 2 of the DCM of a simple undirected graph (the so-called second-order ds problem) is also strongly NP-complete. Their proof uses the basket filling problem; more precisely, they prove that the basket filling problem is reducible to the second-order ds problem, while the three-partition problem is reducible to the second-order ds problem for bipartite graphs. They also show that the three-partition problem can be reduced in polynomial time to the basket filling problem.
As we already mentioned, their reductions do not immediately apply to the (C)DCM recognizability problem, though. A reduction from the second-order ds problem to the (C)DCM recognizability problem would require that we are able, from a given second-order ds instance, to construct a matrix that is the (C)DCM of some graph. It is interesting to observe that our construction also uses the three-partition problem, but in a simpler way than in Erdős and Miklós’s reduction.
5.1 The three-partition problem
Informally, the three-partition problem (shortened hereafter as TPP) consists in deciding if it is possible to partition a list of natural numbers into groups of exactly three integers each, all having the same sum. This problem is very hard: it is strongly NP-complete (i.e., NP-complete even when the input sequence is provided in unary), and it remains so in many restricted cases.
Definition 5.1 (TPP instance). A TPP instance is a sequence of natural numbers such that
and
for all
, where
.
Formally, the three-partition problem is
Problem 5.2 [Three-partition problem (TPP)]. Given a TPP instance , decide whether there exist subsets
such that:
- – the
’s are pairwise disjoint;
- –
for all
;
- –
for all
,
where . If this partition exists, the instance is positive, otherwise it is negative.
We consider a very mild variant, where we assume that all integers are distinct and separated from one another by a certain threshold. This variant is still strongly NP-complete, as shown by the following result.
Theorem 5.3. Problem 5.2 (TPP) is strongly NP-complete (i.e., it is NP-complete even if the input sequence is assumed to be encoded in unary); it remains so even under the following further assumptions:
- – all
’s are distinct,
- –
,
- – for a fixed positive K,
and
for all
.
Proof. The problem is strongly NP-complete as shown in [25]. It remains so even if the input integers are all distinct, as proved in [26]; the fact that the latter result holds also in the presence of the bounds is easy (by adding 2t to each entry in the sequence).
If , then all
’s must be zero or one (because
), so the instance is negative because it contains only one or two elements (recall that the elements in the sequence are all distinct).
Hence, the problem remains strongly NP-complete for distinct integers with . Note that in this case
, so all
are strictly positive. Multiplying all the entries by K we can assume that
and
for all
(multiplying all elements by a constant does not change the problem, because the sequence obtained after the multiplication is a positive instance of the problem if and only if the original sequence was itself a positive instance). □
As a consequence, we can assume that the input sequence of a TPP instance is a TPP instance in the sense of the following definition, which includes all the assumptions of Theorem 5.3 for K = 3.
Definition 5.4 (Special TPP instance). A special TPP instance is a TPP instance with the following additional properties:
,
(for all
) and
.
5.2 NP-Completeness of (C)DCM
Given a special TPP instance , let
We define a matrix as follows:
- – the first 3m rows of
have the form
for
,
- – the following s rows of
have the form
,
- – the last m rows of
have the form
.
Intuitively, if a is a positive instance of TPP, it is possible to show that is the DCM of an undirected graph
. This fact will be part of the proof of Theorem 5.5, but we want to provide immediately a visual clue to this fact for
. To keep the graph small, we use a sequence that fails to satisfy the more restrictive conditions of Theorem 5.3. The graph (see Fig 4) contains m (in this case, 2) connected components, one for each
. All components contain three vertices (representing the three integers of the input sequence belonging to
) connected to t vertices (this is possible because the sum of the three integers is always t), which are further connected to a single vertex (of degree t).
Theorem 5.5. Given a special TPP instance , the following two statements are equivalent:
- a is a positive instance of Problem 5.2;
is the DCM of an undirected graph.
Proof. (1) (2). Let
be a partition of
showing that the sequence is a positive instance. Build an undirected graph
with n vertices as follows:
- – there is one vertex for every integer in the sequence a; we will call these vertices
;
- – there are t vertices for every class
; we will call them
for each
;
- – there is one vertex
for every class
,
;
- – for every
, suppose
: we add edges
for every
;
for every
;
for every
;
- – for every
and
, we add an edge
.
Each vertex has degree
, and each vertex
has degree 2 (because it is connected to
for exactly one
, and to
). Each
has degree t. All vertices related to j (i.e.,
for
,
for
, and
) form one connected component with t + 4 vertices. There are m such components.
If ,
has only vertex
at distance two, and
vertices at distance three (all the vertices of the form
except those that are neighbors of
). Finally,
has two vertices at distance four (exactly the other two vertices of the form
for
, and
: there are two of them, because
). Hence the row related to
is of the form
.
The vertices at distance two from are all the other
(there are
of them). The vertices at distance three are 2 (the vertices of the form
for
, except the only one that is a direct neighbor of
). Hence, the row related to
is of the form
.
Finally, the vertices at distance two from are all the vertices of the form
for
(there are 3 of them). Thus, the row related to
is of the form
.
It is immediate to check that the DCM of is
, meaning that
is a DCM.
(2) (1). Suppose that
is the DCM of some undirected graph
. The graph has n vertices, divided into three groups:
- – Group I: the first 3m vertices all have degree larger than 2 (because a is a TPP instance such that all of its elements are ≥3); group I corresponds to rows of the form
;
- – Group II: the next s vertices all have degree 2; group II corresponds to rows of the form
;
- – Group III: the last m vertices all have degree t (which is larger than a1, hence of all
’s, because
); group III corresponds to rows of the form
;
Observe that every row of has sum equal to t + 4. Hence the graph has m connected components, with t + 4 vertices each. It is also worth taking note of the form of the rows of the CDCM of
:
- – Group I:
,
- – Group II:
,
- – Group III:
.
Consider any component X of , and suppose that this component contains A vertices of group I, B vertices of group II and C vertices of group III. The degree sequence of this component is (after reordering):
for some choice of . Note that A + B + C = t + 4 (the size of each component).
Start by considering a vertex of group II: it is connected to two vertices j1 and j2, which may each belong, in principle, to one of the three groups. We shall apply Theorem 4.13 to the row of vertex i in the CDCM of
: Table 1 describes the possible intervals of integers for the third value in the row of i depending on how we choose j1 and j2.
The third value in the row of the CDCM for group II is t + 2, and the only intervals containing t + 2 are those in the last column (since , t is certainly larger than 6). This means that every vertex of group II is connected to at least one vertex of group III. As a consequence, B > 0 implies C > 0.
On the other hand, applying again Theorem 4.13, no vertex of group I can be connected to a node of group III, because
. Also, no two vertices of group I can be connected to each other: suppose, by contradiction that a vertex of degree
is connected to a vertex of degree
with
. Then we should have (by Theorem 4.13)
, that is
, which is impossible because
. We conclude that vertices of group I are connected only to vertices of group II. As a consequence, A > 0 implies B > 0.
For the reasons above, every component of must contain at least one vertex of group III. Since there are m components and exactly m vertices of group III, we conclude that each component contains exactly one vertex of group III, that is, C = 1.
The A vertices of group I in component X are all connected to vertices of group II (this is, as we discussed above, the only possibility for them), and those vertices of group II must be distinct (they have degree 2, and each of them is connected to at least one vertex of group III); so there must be at least vertices of group II in the component, say
for some
. Assume for the moment that
.
The only vertex of group III is itself connected to t vertices of group II, so we conclude that and B = t. Since A + B + C = t + 4, we have A + t + 1 = t + 4, hence A = 3.
These conditions, together with the fact that this property holds for all components of , allow us to conclude that a is a positive instance of TPP.
Finally, note that must be zero, because if even one component contained some extra vertex of group II, then altogether there would be more than s vertices of group II in the graph, which is impossible. □
Corollary 5.6. Recognizing whether a given matrix is the (C)DCM of an undirected graph is strongly NP-complete.
Proof. Theorem 5.5 reduces TPP to recognizing DCMs, hence the result follows by Theorem 5.3. The fact that TPP is strongly NP-complete is needed for the construction to be admissible (the size of the matrix is pseudopolynomial in the input sequence a). □
Observe that our construction does not directly tell us if the problem of recognizing whether a matrix is the (C)DCM of an arbitrary directed graph is also NP-complete. Incidentally, it is easy to see that is a negative instance of TPP satisfying the conditions in the statement of Theorem 5.3: still, we were able to find a directed graph whose DCM is
. In other words, the construction we exhibited is not enough to conclude that recognizing general (C)DCMs is itself an NP-complete problem, although we believe so.
6 Graph operations and (C)DCMs
In this section, we want to show that, while the recognition problem of (C)DCMs is extremely hard, distance-count matrices exhibit a rich algebraic structure that matches natural operations between the underlying graphs. This fact can be used as the starting point for obtaining positive and negative results about DCMs, by exploiting this modular correspondence. We start with a precise definition of what we want to describe:
Definition 6.1 (DCM-stable graph operation). A graph operation ⊗ is DCM-stable if there is a matrix operation such that, for any two graphs
and
we have
It is DCM-stable on undirected graphs if the above equality occurs only for undirected graphs ,
.
Note that here and in the following, the identity of (C)DCM matrices is intended up to row permutations. Checking whether A = B can be accomplished by sorting the rows of each matrix in lexicographic order, and then checking if the resulting matrices are identical.
We will show that many common graph operations are DCM-stable. In particular, we will consider disjoint union, subgraphs, and different types of graph products. In the rest of the paper, all results apply to general directed graphs, unless otherwise specified.
6.1 Disjoint union
The disjoint union of graphs is possibly the simplest binary graph operation: it consists of taking the actual union of nodes and arcs, without any extra arcs added between the two graphs. Since the two node sets may partially overlap, it is formally necessary to label each node so that we know where it comes from:
Definition 6.2 (Disjoint union). Given graphs and
, their disjoint union
has node set
and contains an arc ((x,0),(y,0)) for every arc
, and an arc ((x,1),(y,1)) for every arc
.
It is nonetheless convenient (and in fact equivalent, up to node renaming) to assume that and
are disjoint sets, and to simply let
Now paths (hence, shortest paths) in are simply paths in the two original graphs, which implies that (Fig 5):
Proposition 6.3 Let and
be two graphs, and
denote their disjoint union. Then, for all
we have:
Hence:
Theorem 6.4 Let and
be two graphs, and
denote their disjoint union. Then for every
and natural number k,
Corollary 6.5 Disjoint union ⊕ of graphs is DCM-stable.
6.2 Standard graph products
Graph products [13], in general, are binary graph operations between a graph and another graph
that yield a graph whose node set is the cartesian product
. The arcs in the product can be defined in different ways, yielding different forms of graph product. It is often useful to think of the arcs in
and
as possible “moves in a game”, and the product as a way to compose those moves. In particular, [13, Chapter 5] considers four so-called standard products: strong, cartesian, lexicographic, and Kronecker product. Note that some results about distance degree sequences in these products are already known in the literature [27–30]; here we will extend those results to the full distance-count matrix.
6.2.1 Strong product.
Let us start with the strong product (see Fig 6). Here, moves in the product correspond to moves in at least one graph (possibly both). The following is a formal definition:
Definition 6.6 (Strong product). Given graphs and
, their strong product
has node set
and contains an arc
if and only if one of the following is true:
and
;
and
;
and
.
A path in is a sequence of moves in either graph, or in both of them. More precisely, any path
can be projected onto
(
, respectively) by taking
(
, resp.) and removing repeated consecutive occurrences of the same node. Hence, every path of length k from (x,y) to
in
yields a path of length at most k from x to
in
and a path of length at most k from y to
in
. Hence [13],
On the other hand, it is easy to see that this is an equality, by taking a path that follows the shortest path from x to in
and the shortest path from y to
in
in parallel until this is possible, and then remaining still in either graph and continuing in the other one for the remaining steps. As a consequence:
Proposition 6.7 (Proposition 5.4 of [13]). Let and
be two graphs, and
denote their strong product. Then for every
we have
Note that this proposition (like other similar ones that we will be using from [13]) holds also in the directed case. A consequence of Proposition 6.7 is the following:
Theorem 6.8. Let and
be two graphs, and let
denote their strong product. Then for every
and natural number k,
Proof. The set A of nodes such that
consists of those for which
Consider all the pairs of natural numbers such that
: we can characterize A as the union of all pairs
such that
and
. In other words, for
we must have either h1 = k or h2 = k (or both). So we can count the cardinality of A as follows:
where the last summand is needed to remove the pairs that are both at distance k. □
Corollary 6.9. Strong product of graphs is DCM-stable.
6.2.2 Cartesian product.
The cartesian product (see Fig 7) is a different form of product where moves in the product correspond to moves in one of the graphs, but not both. The following is a formal definition:
Definition 6.10 (Cartesian product). Given graphs and
, their cartesian product
has node set
and contains an arc
if and only if one of the following is true:
and
;
and
.
Following the same line of reasoning as for the strong product, we have:
Proposition 6.11 (Proposition 5.1 of [13]). Let and
be two graphs, and
denote their cartesian product. Then for every
we have
Interestingly, the converse of this fact is also true
Proposition 6.12 Let and
be two graphs, and
be a graph with
. Suppose that for every
we have
Then .
Proof. We have that if and only if
, which happens if and only if
. The latter is equivalent to
and
, or
and
, so
.
An immediate consequence of Proposition 6.11 is the following
Theorem 6.13. Let and
be two graphs, and
denote their cartesian product. Then for every
and natural number k,
Recalling the definition of exponential-decay centrality, we have that
hence
for every . More is true:
Theorem 6.14. Let and
be two graphs, and
be a graph with node set
. Assume moreover that for any
and for at least
distinct values
we have
Then (5) holds for any ; moreover, for every
and natural number k,
Proof. Remember that and similarly for
and
, so we have
for at least values
. Since on both sides of the equation we have polynomials of degree at most
, we conclude that those polynomials in fact coincide; that is,
i.e., for all t
□
Corollary 6.15. Cartesian product of graphs is DCM-stable.
6.2.3 Lexicographic product.
The third common type of graph product [13] is the following (see Fig 8):
Definition 6.16 (Lexicographic product). Given graphs and
, their lexicographic product
has node set
and contains an arc
if and only if one of the following is true:
;
and
.
Distances in the lexicographic product can be characterized as follows for the undirected case:
Proposition 6.17 (Proposition 5.12 of [13]). Let and
be two undirected graphs, and
. Then:
The directed version of the same property is trickier: the 2 appearing in the lemma would become the length of the shortest cycle of involving x, information that cannot be deduced from the DCM of
itself.
Theorem 6.18 Let and
be two undirected graphs, and
denote their lexicographic product. Then for every
and natural number k,
- •. if
then
- •. else
Proof. Case 1. Let us consider the case first. By Proposition 6.17, in this case we have
that is, more explicitly,
Now, for any given (x,y) and natural number k, the pairs that are at distance k from (x,y) are:
- just (x,y), if k = 0;
- if k = 1, we have all the pairs
with
, for every possible
, plus all the pairs
with
;
- if k = 2, we have all the pairs
with
, for every possible
, plus all the pairs
with
(all possible
, except when
or
);
- if k > 2, we have all the pairs
with
, for every possible
.
Case 2. In the case , then
for all k > 0. Hence
Now, for any given (x,y) and natural number k, the pairs that are at distance k > 0 from (x,y) are those with
(there are none), plus all those of the form
with
.□
Corollary 6.19. Lexicographic product ∘ of graphs is DCM-stable for undirected graphs.
This result is anyway not true for directed graphs. To prove that the lexicographic product is not DCM-stable, we must provide four digraphs ,
,
,
such that
whereas
This fact implies, clearly, that cannot be computed directly from
and
.
We choose the graphs ,
and
as in Fig 9 (and let
). It is immediate to observe that
To show that
we need the following:
Definition 6.20 (Girth). For a graph and a node
, the local girth of
at x,
, is the length (number of arcs) of the shortest non-empty path from x to itself in
(∞ if such a path does not exist). Define
Then we have:
Theorem 6.21. Given two graphs and
we have
Proof. If are two nodes realizing
, then for any
, the distance from (x,y) to
in
is exactly
. On the other hand, for any
and
we can build in
a path from (x,y) to
of length
(by leaving the first coordinate fixed and moving the second coordinate along the path from y to
in
), and another path of length
(by moving along the non-empty path from x to x in
, while jumping from y to
in
at any point along the path). □
As a consequence:
Corollary 6.22. The lexicographic product is not DCM-stable on directed graphs.
Proof. We must prove that , for the graphs in Fig 9. We observe that
,
,
,
. Hence:
Two graphs with different finite diameters must have different DCMs. □
6.2.4 Kronecker product.
Not all natural graph operations (in particular: not all graph products) are DCM-stable. One example [13] is the following (see Fig 10):
Definition 6.23 (Kronecker (or tensor) product). Given graphs and
, their Kronecker product
has node set
and contains an arc
if and only if
and
.
Note that a path in can always be obtained by travelling in parallel along two paths of the same length (one in
and one in
). Even if either can be non-simple, the result might still be simple and in fact even a shortest path.
As we did for the lexicographic product, we provide an undirected counterexample: consider ,
and
defined in Fig 11. We have that, up to node permutation,
Nonetheless, from Theorem 1 of [31] we know that the Kronecker product of two connected graphs is connected if and only if one of them contains an odd cycle. In our example, only contains an odd cycle. This implies that the graph
is connected, while
is not, which means that
.
Corollary 6.24. Kronecker product is not DCM-stable. It is not even DCM-stable for undirected graphs.
6.3 Corona product
The so-called corona product was originally defined by Harary and Frucht [32] for undirected graphs; here, we are going to borrow the three extensions of this product for the directed case proposed in [33], called forward, backward, and symmetric.
Definition 6.25 (Corona product). Given graphs and
, their forward corona product
, backward corona product
, and symmetric corona product
are the graphs having node set
and such that:
- all the arcs of
also belong to all the corona products;
- for every
and any
, there is an arc from (x,y) to
in all the corona products;
- for every
and
- – there is an arc from x to (x,y) in
;
- – there is an arc from (x,y) to x in
;
- – there are two symmetric arcs connecting x with (x,y) in
.
- – there is an arc from x to (x,y) in
Alternatively, we can say that contains one copy of
(the so-called “center graph”) and one copy of
for each node of
, and the three products differ only in the direction of the arcs between each node
and the nodes of the copy of
associated with it. Note that
yields the same result as the original definition of the product if
and
are undirected. In such a case, we can refer to this operation simply as
(refer to Fig 12 for an example).
In the directed versions, the edges connecting to the copies of
are directed outwards in
, inwards in
.
Proposition 6.26. Let and
be two graphs, and let
,
, and
. Then, for every
and
, the distances between nodes in
,
and
are shown in Table 2.
As a consequence:
Theorem 6.27. Let and
be two graphs, and let
,
, and
. Then, for every
and
:
and
;
and
;
and
Proof. Let us start with . Since it belongs to the center graph, regardless of the type of corona product we are considering, at a given distance k it has at least the same number of nodes it has at distance k in
. Additionally, for each
at distance
in
, in
and
node x has at distance k the
nodes belonging to the copy of
associated with (and, thus, connected to)
. Note that when k = 0,
, thus
, and when k = 1 the
nodes at distance 1 to x in
and
are those belonging to the copy of
associated to x itself. Hence, in both cases, everything holds.
Moving to node (x,y), it is easy to see that in and
it has at least the same number of nodes that y has at distance k in
. Additionally, in
in k steps (x,y) can also be reached by those nodes that can reach x in
steps in
. In
, instead, there are several cases to consider, based on the value of k (where k = 0 trivially holds). If k = 1, the nodes whose distance to (x,y) is 1 are the in-neighbors of y in
, plus x. When k = 2, instead, the nodes that can reach (x,y) in 2 steps are the in-neighbors of x in
, plus the
nodes of the copy of
associated with x, from which we have to remove the in-neighbors of y and y itself. Finally, when k > 2, the nodes whose distance to (x,y) is k are those at distance
to x in
, plus those belonging to copies of
associated with the nodes
such that
. □
Corollary 6.28. The forward , backward
, and symmetric
corona products of graphs are DCM-stable.
7 Conclusions and future work
As mentioned, our negative result is especially relevant in the area of axiomatic centrality, when one tries to build counterexamples for specific properties of geometric centralities. On the other hand, there are families of graphs for which the DCM decision problem is feasible (e.g., out-directed trees), and we have shown that many natural and well-known graph operations can be expressed as operations between the corresponding distance-count matrices. Table 3 summarizes the results we obtained for the operations we considered. Our exploration in this direction is, at the moment, just a ballon d’essai, but it paves the way to pursue the problem of exploring the algebraic structure of DCMs to obtain positive and negative results on geometric centralities.
One problem that remains open is whether Theorem 5.5 can be extended to the case of general (not necessarily undirected) graphs. In particular, as we said, there are TPP instances a such that the matrix is the DCM of some directed graph, even if a is a negative instance of Problem 5.2. We know that, if this happens, it must be a non-symmetric graph, because the symmetric case is already ruled out by our proof. We believe that also in the general case the problem remains NP-complete, but a formal proof of this fact is still missing.
Acknowledgments
The authors would like to thank the anonymous reviewers for their useful comments and suggestions, which helped us address a few issues and improve the presentation of the paper.
References
- 1. Boldi P, Vigna S. Axioms for Centrality. Internet Math. 2014;10(3-4):222–62.
- 2. Bavelas A. Communication patterns in task-oriented groups. J Acoust Soc Am. 1950;22(6):725–30.
- 3.
Lin N. Foundations of social research. New York: McGraw-Hill; 1976.
- 4.
Kishi G. On centrality functions of a graph. Lecture Notes in Computer Science. Springer Berlin Heidelberg; 1981. p. 45–52. https://doi.org/10.1007/3-540-10704-5_5
- 5. Kishi G, Takeuchi M. A type of centrality functions for a directed graph. Electron Comm Jpn Pt I. 1983;66(5):38–47.
- 6. Skibski O, Sosnowska J. Axioms for distance-based centralities. AAAI. 2018;32(1).
- 7. Boldi P, Furia F, Prezioso C. Properties and expressivity of linear geometric centralities. Theoretical Computer Science. 2026;1060:115640.
- 8. Leskovec J, Kleinberg J, Faloutsos C. Graph evolution: densification and shrinking diameters. ACM Trans Knowl Discov Data. 2007;1(1):2-es.
- 9.
Backstrom L, Boldi P, Rosa M, Ugander J, Vigna S. Four degrees of separation. In: ACM Web Science 2012: Conference Proceedings, 2012. p. 45–54.
- 10. Wiener H. Structural determination of paraffin boiling points. J Am Chem Soc. 1947;69(1):17–20. pmid:20291038
- 11.
Rouvray DH. The rich legacy of half a century of the Wiener index. Topology in Chemistry. Elsevier; 2002. p. 16–37.
- 12.
Boldi P, Vigna S. In-core computation of geometric centralities with HyperBall: a hundred billion nodes and beyond. In: 2013 IEEE 13th International Conference on Data Mining Workshops, 2013. p. 621–8. https://doi.org/10.1109/icdmw.2013.10
- 13.
Hammack RH, Imrich W, Klavžar S, Imrich W, Klavžar S. Handbook of product graphs. Boca Raton: CRC Press. 2011.
- 14. Huilgol MI. Distance degree regular graphs and distance degree injective graphs: an overview. Journal of Discrete Mathematics. 2014;2014:1–12.
- 15. Erdős P, Gallai T. Gráfok előírt fokszámú pontokkal. Matematikai Lapok. 1960;11:264–74.
- 16. Havel V. A remark on the existence of finite graphs. Casopis Pest Mat. 1955;80:477–80.
- 17. Hakimi SL. On realizability of a set of integers as degrees of the vertices of a linear graph II. Uniqueness. Journal of the Society for Industrial and Applied Mathematics. 1963;11(1):135–47.
- 18. Kleitman DJ, Wang DL. Algorithms for constructing graphs and digraphs with given valences and factors. Discrete Mathematics. 1973;6(1):79–88.
- 19. Erdős PL, Miklós I. Not all simple looking degree sequence problems are easy. J Comb. 2018;9(3):553–66.
- 20.
Bollobás B. Modern graph theory. Springer–Verlag. 1998.
- 21.
Brandes U, Erlebach T. Network analysis: methodological foundations. Berlin: Springer-Verlag; 2005.
- 22.
Boldi P, Furia F, Prezioso C. Linear geometric centralities. Lecture Notes in Computer Science. Springer Nature Switzerland; 2025. p. 1–16. https://doi.org/10.1007/978-3-031-92898-7_1
- 23. Boldi P, D’Ascenzo D, Furia F, Vigna S. Score and rank semi-monotonicity for closeness, betweenness, and distance–decay centralities. Soc Netw Anal Min. 2024;14(1).
- 24.
Buckley F, Harary F. Distance in Graphs. Redwood City, Calif.: Addison-Wesley Pub. Co.; 1990.
- 25.
Garey MR, Johnson DS. Computers and Intractability: A Guide to the Theory of NP-Completeness. W.H. Freeman and Company; 1979.
- 26. Hulett H, Will TG, Woeginger GJ. Multigraph realizations of degree sequences: Maximization is easy, minimization is hard. Operations Research Letters. 2008;36(5):594–6.
- 27. Huilgol MI, Rajeshwari M, Ulla SSA. Products of distance degree regular and distance degree injective graphs. Journal of Discrete Mathematical Sciences and Cryptography. 2012;15(4–5):303–14.
- 28. Huilgol MI, Divya B, Balasubramanian K. Distance degree vector and scalar sequences of corona and lexicographic products of graphs with applications to dynamic NMR and dynamics of nonrigid molecules and proteins. Theor Chem Acc. 2021;140(3).
- 29. Huilgol MI, Sriram V. New results on distance degree sequences of graphs. Malaya J Mat. 2019;7(2):345–52.
- 30. Huilgol MI, Sriram V, Balasubramanian K. Tensor and Cartesian products for nanotori, nanotubes and zig–zag polyhex nanotubes and their applications to13C NMR spectroscopy. Molecular Physics. 2020;119(4):e1817594.
- 31. Weichsel PM. The kronecker product of graphs. Proceedings of the American Mathematical Society. 1962;13(1):47–52.
- 32. Frucht R, Harary F. On the corona of two graphs. Aeq Math. 1970;4(3):322–5.
- 33.
Cavers M, Maghsoudi F, Miraftab B. Spectra of corona products of digraphs. 2025. https://doi.org/arXiv:2509.14481