Skip to content

Finding the matching(s) between two graphs

Inno Fang edited this page Jun 3, 2019 · 3 revisions

You can handle subgraph isomorphism result by implementing callback method, and determine whether only one result is needed by returning values from callback methods.

Finding the first matching

Matcher.match(state, new Matcher.Visitor() {
    @Override
    public boolean visit(HashMap<Integer, Integer> mapping) {
        // mapping is the result of isomorphism
        System.out.println(mapping);
        return true;
    }
})

Also, if you want to use lambda to refine above code

Matcher.match(state, mapping -> {
    // mapping is the result of isomorphism
    System.out.println(mapping);
    return true;
})

Finding all the matchings

Matcher.match(state, new Matcher.Visitor() {
    @Override
    public boolean visit(HashMap<Integer, Integer> mapping) {
        // mapping is the result of isomorphism
        System.out.println(mapping);
        return false;
    }
})

Also, if you want to use lambda to refine above code

Matcher.match(state, mapping -> {
    // mapping is the result of isomorphism
    System.out.println(mapping);
    return true;
})

Clone this wiki locally