Skip to main content

A subgraph matching programming library.

Project description

openGraphMatching

A Python Graph/Subgraph Matching programming library. Based on openGraphMatching and the framework provided, you can develop and test different subgraph matching algorithms efficiently. What's more, since the codebase is Python-based, algorithms with neural networks can be integrated easily with traditional subgraph matching algorithms.

Usage

Prerequisite pytorch>=1.6, networkx, pytorch-geometric, deepsnap.

A detailed environment configration can be found in env.yml.

The BaseMatcher is the minium implementation of subgraph matching algorithm.

Here is the demo code for running GraphQL algorithm:

import openGraphMatching.matcher as matcher

# Prepare query graph q and target graph G in advance. q and G are networkx instance.

m = matcher.GQLMatcher(G) # Initialize the object with targer graph G
m.is_subgraph_match(q) # Run the check match process

Quickstart

  • Clone this repository: git clone https://github.com/chang2000/openGraphMatching

  • Install all prerequisite

    If you are using conda-like package manager, we provide the conda environment file env.yml for this package. You may refer to this link to install a conda environment by a environment file. In short, use this command conda env create -f env.yml. Then a conda envrionment named ogm is created.

  • pip install openGraphMatching to install this package.

  • Enter the examples folder, then run python exact_subgraph_match_validate.pyto run the validation demo of this package.

Internals

Each matcher follows the filtering->ordering->enumerating design pattern. In the directory matcher there are three files: filters.py, orders.py,enumeraters.py, where each file contains the general algorithms.

For example, in the graphQL matcher, the code pipeline is like:

from openGraphMatching import BaseMatcher
from openGraphMatching import filters as f
from openGraphMatching import orders as o
from openGraphMatching import enumeraters as e

class GQLMatcher(BaseMatcher):
    def __init__(self, G):
        super().__init__(G)

    def filtering(self, q):
        prefilter = f.Filter(self.G)
        return prefilter.gql_filtering(q)

    def ordering(self, q, candidates):
        orderer = o.Order(self.G)
        return orderer.gql_order(q, candidates)

    def enumerate(self, q, imd, order, i):
        enu = e.Enumerater(self.G)
        enu.normal_enum(q, imd, order, i)
        return enu.res_getter()

    def is_subgraph_match(self, q):
      	# Some verbose and statistics are skipped here
        candidates = self.filtering(q)
        order = self.ordering(q, candidates)
        match_list = self.enumerate(q, candidates, order, 1)
        return match_list

Misc

  1. Validate the correctness of algorithm.

    • We use HPRD (9460 nodes, 34998 edges) to validate the correctness considering the time consuming and program performance.
    • We provides 200 quries(dense, 16 nodes).
    • A correctness checker is implemented in utils.py.
    • Expected result of all the matching are provided in expected.res. Refer to the dataset validate for more information.
  2. The data format of the datasets

    1. For each .graph file, the first line will always be t x y where x and y are two int indicates the number of nodes and edges

    2. Vertex data v v_id v_label v_degree

    3. Edge data e v_id v_id

Side word

  • Cannot handle yeast well even it has a smaller dataset size, since around 10% of nodes left for 3000 nodes.
  • The observation above inspires us to combine the traditional subgraph matching methods and the neural methods together.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openGraphMatching-0.2.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openGraphMatching-0.2.1-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file openGraphMatching-0.2.1.tar.gz.

File metadata

  • Download URL: openGraphMatching-0.2.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for openGraphMatching-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f61d81ada47144a1549aea4a871ffeeb39cb0d093897724ef58301b10220c7d4
MD5 226282486de5dd49834fb8a74ee4e707
BLAKE2b-256 de5cd1dfa54a99c0ebaf1a968a7d2bad0f7180d662a5ae96d638212eadb60d2d

See more details on using hashes here.

File details

Details for the file openGraphMatching-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: openGraphMatching-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for openGraphMatching-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc81818b560f2862a9f2c80bf77173a402a1f47eea8958b0229715edaf935dd9
MD5 2a498229640d6c4d4dafe3c4073c41d6
BLAKE2b-256 ca49599fbf4c54f5f4d5bb72d076cfb83924c4eec096aedc32ccb4bbbd5fa832

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page