
WSDM ’23, February 27-March 3, 2023, Singapore, Singapore Zexi Huang, Mert Kosan, Sourav Medya, Sayan Ranu, and Ambuj Singh
classied by a GNN to be mutagenic. Factual explainers can attribute
the subgraph containing the carbon-hydrogen bond to the cause of
mutagenicity, while counterfactual explainers provide an eective
way (i.e., a recourse) to turn formaldehyde into formic acid, which
is non-mutagenic, by replacing a hydrogen atom with a hydroxyl.
In this work, we focus on counterfactual explanations. Our work
is based on the observation that existing counterfactual explain-
ers [
20
,
40
,
46
,
47
] for graphs take a local perspective, generating
counterfactual examples for individual input graphs. However, this
approach has two key limitations:
•Lack of global insights:
It is desirable to oer insights that
generalize across a multitude of data graphs. For example, in-
stead of providing formic acid as a counterfactual example to
formaldehyde, we can summarize global recourse rules such as
“Given any molecule with a carbonyl group (carbon-oxygen double
bond), it needs a hydroxy to be non-mutagenic”. This focus on
global counterfactual explanation promises to provide higher-
level insights that are complementary to those obtained from
local counterfactual explanations.
•Information overload:
The primary motivation behind coun-
terfactual analysis is to provide human-intelligible explanations.
With this objective, consider real-world graph datasets that rou-
tinely contain thousands to millions of graphs. Owing to instance-
specic counterfactual explanations, the number of counterfac-
tual graphs grows linearly with the graph dataset size. Conse-
quently, the sheer volume of counterfactual graphs overloads
human cognitive ability to process this information. Hence, the
initial motivation of providing human-intelligible insights is lost
if one does not obtain a holistic view of the counterfactual graphs.
Contributions:
In this paper, we study the problem of model-
agnostic, global counterfactual explanations of GNNs for graph
classication. More specically, given a graph dataset, our goal is
to counterfactually explain the largest number of input graphs with
a small number of counterfactuals. As we will demonstrate later
in our experiments, this formulation naturally forces us to remove
redundancy from instance-specic counterfactual explanations and
hence has higher information density. Algorithmically, the pro-
posed problem introduces new challenges. We theoretically estab-
lish that the proposed problem is NP-hard. Furthermore, the space
of all possible counterfactual graphs itself is exponential. Our work
overcomes these challenges and makes the following contributions:
•Novel formulation:
We formulate the novel problem of global
counterfactual reasoning/explanation of GNNs for graph classi-
cation. In contrast to existing works on counterfactual reasoning
that only generate instance-specic examples, we provide an
explanation on the global behavior of the model.
•Algorithm design:
While the problem is NP-hard, we propose
GCFExplainer, which organizes the exponential search space as
an edit map. We then perform vertex-reinforced random walks on
it to generate diverse, representative counterfactual candidates,
which are greedily summarized as the global explanation.
•Experiments:
We conduct extensive experiments on real-world
datasets to validate the eectiveness of the proposed method.
Results show that GCFExplainer not only provides important
high-level insights on the model behavior but also outperforms
state-of-the-art baselines related to counterfactual reasoning in
various recourse quality metrics.
2 GLOBAL COUNTERFACTUAL
EXPLANATIONS
This section introduces the global counterfactual explanation (GCE)
problem for graph classication. We start with the background on lo-
cal counterfactual reasoning. Then, we propose a representation of
the global recourse rule that provides a high-level counterfactual un-
derstanding of the classier behavior. Finally, we introduce quality
measures for recourse rules and formally dene the GCE problem.
2.1 Local Counterfactual
Consider a graph
𝐺=(𝑉 , 𝐸)
, where
𝑉
and
𝐸
are the sets of (labelled)
nodes and edges respectively. A (binary) graph classier (e.g., a
GNN)
𝜙
classies
𝐺
into either the undesired class (
𝜙(𝐺)=
0) or the
desired one (
𝜙(𝐺)=
1). An explanation of
𝜙
seeks to answer how
these predictions are made. Those based on factual reasoning ana-
lyze what properties
𝐺
possesses to be classied in the current class
while those based on counterfactual reasoning nd what properties
𝐺needs to be assigned to the opposite class.
Existing counterfactual explanation methods take a local per-
spective. Specically, for each input graph
𝐺
, they nd a
counter-
factual
(graph)
𝐶
that is somewhat similar to
𝐺
but is assigned
to a dierent class. Without loss of generality, let
𝐺
belong to the
undesired class, i.e.,
𝜙(𝐺)=
0, then the counterfactual
𝐶
satises
𝜙(𝐶)=
1. The similarity between
𝐶
and
𝐺
is quantied by a prede-
ned distance metric
𝑑
, for example, the number of added/removed
edges [2, 19].
In our work, we consider the graph edit distance (GED) [
33
], a
more general distance measure, as the distance function to account
for other types of changes. Specically,
GED(𝐺1, 𝐺2)
counts the
minimum number of “edits” to convert
𝐺1
to
𝐺2
. An “edit” can be
the addition or removal of edges and nodes, or change of node
labels (see Figure 2). Moreover, to account for graphs of dierent
sizes, we normalize the GED by the sizes of graphs:
GED(𝐺1, 𝐺2)=
GED(𝐺1, 𝐺2)/(|𝑉1| + |𝑉2| + |𝐸1| + |𝐸2|)
. Nonetheless, our method
can be applied with other graph distance metrics, such as those
based on graph kernels (e.g., RW [4], NSPDG [6], WL [35]).
Node/edge addition
Node/edge
removal Node label change
Figure 2: Edits between graphs.
The distance function measures the quality of the counterfactual
found by the explanation model. Ideally, the counterfactual
𝐶
should
be very close to the input graph
𝐺
while belonging to a dierent
class. Formally, we dene the counterfactuals that are within a
certain distance
𝜃
from the input graph as
close counterfactuals
.
Definition
1 (Close Counterfactual). Given the GNN clas-
sier
𝜙
, distance parameter
𝜃
, and an input graph
𝐺
with undesired
2