borgwardtlab / p-wl Goto Github PK
View Code? Open in Web Editor NEWA Persistent Weisfeiler–Lehman Procedure for Graph Classification
License: MIT License
A Persistent Weisfeiler–Lehman Procedure for Graph Classification
License: MIT License
I found the example code at ReadMe as below. However, the data folder is not under the src folder. Reported "Can't find file..."
$ cd src
$ python main.py -c -n 0 -p 1 data/MUTAG/*.gml -l data/MUTAG/Labels.txt
Hello,
I'm playing around with the code in a Jupyter notebook and wasn't sure about the following result when I consider permuting the node indices of a simple graph. I expected that when I permute the node indices (ie. to isomorphic graphs) then I will get the same P-WL-C representation - but I'm not.
My code (after the necessary imports) is below and hopefully I permuted the graphs correctly (worth verifying first or my question is moot!).
Thanks so much for clarifying if you can.
Scott
# Quick double check to make sure that results are invariant
pwl = PersistentWeisfeilerLehman(
use_cycle_persistence=True,
use_original_features=False,
use_label_persistence=True,
store_persistence_diagrams=True,
metric='minkowski',
p=1,
smooth=False)
# Graph taken from Figure 2 of Shervashidze, 2011
graph1 = ig.Graph([(0,2),(1,2),(2,3),(2,4),(3,4),(3,5),(4,5)])
graph1.vs['label'] = [1,1,4,3,5,2]
# Permute the same graph for different node ordering
# (0 5)(1 4)(2 3)
graph2 = ig.Graph([(0,1),(0,2),(1,2),(1,3),(2,3),(3,4),(3,5)])
graph2.vs['label'] = [2,5,3,4,1,1]
# Permute again for a third graph: (2 3)
graph3 = ig.Graph([(0,3),(1,3),(2,3),(2,4),(2,5),(3,4),(4,5)])
graph3.vs['label'] = [1,1,3,4,5,2]
graphs = [graph1,graph2,graph3]
pwl.transform(graphs, 1)
Output:
(array([[ 4., 2., 2., 2., 2., 0., 0., 2., 4., 2., 14., 7., 4.,
5., 7., 0., 7., 0., 12., 5.],
[ 4., 2., 2., 2., 2., 0., 2., 4., 2., 0., 14., 7., 7.,
4., 5., 0., 7., 12., 0., 5.],
[ 4., 2., 2., 2., 2., 0., 2., 0., 4., 2., 14., 7., 4.,
5., 7., 0., 7., 0., 12., 5.]]), {0: 10, 1: 10})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.