Skip to content

Node with No Outgoing Edge in WL Kernel #119

@JohnLyu2

Description

@JohnLyu2

Describe the bug
Not sure this is a bug. Does the WL kernel assume the input graph is undirected? From the code, my understanding is that the kernel labels a node only considering its outgoing neighbors. I think this algorithm can work with directed graphs, but now if there is a node without outgoing edge, it will produce error.

To Reproduce

from grakel import Graph
from grakel.kernels import WeisfeilerLehman

graph = {
    0: [1, 2],
    1: [2],
    2: []
}
node_labels1 = {0: "A", 1: "B", 2: "C"}
g = Graph(graph, node_labels=node_labels1)
graphs = [g]
wl_kernel = WeisfeilerLehman(n_iter=2, normalize=True)
K = wl_kernel.fit_transform(graphs)

The code above will report a "KeyError: 2" from line 222, in generate_graphs, "grakel/kernels/weisfeiler_lehman.py"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions