Code Monkey home page Code Monkey logo

p-wl's Issues

Example doesn't work

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

Invariance to node permutation?

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})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.