Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node with No Outgoing Edge in WL Kernel #119

Open
JohnLyu2 opened this issue Dec 20, 2024 · 0 comments
Open

Node with No Outgoing Edge in WL Kernel #119

JohnLyu2 opened this issue Dec 20, 2024 · 0 comments

Comments

@JohnLyu2
Copy link

JohnLyu2 commented Dec 20, 2024

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant