Git Product home page Git Product logo

mcs's Introduction

Alt text

Maximum Common Subgraph

An algorithm that given two graphs allows you to:

  • compute their similarity (or correlation);
  • construct the maximum common subgraph (MCS) also called the maximum common substructure.

It is a simple solution to the maximum common sugraph problem for small graphs.

Installation

If you're using node

Simply install it via npm:

npm install maximum-common-subgraph

Done! You can now do:

{Graph, GraphEdge, GraphNode, Points, constructMCS} = require('maximum-common-subgraph')

If you want to use it in the browser

Download the mcs_browser_module.js file into your working directory and then do:

<script type="module">
  import {Graph, GraphEdge, GraphNode, Points, constructMCS} from './mcs_browser_module.js';
  
  ....js code goes here....
</script>

If you're using TypeScript

Download the index.ts file into your working directory and then do:

import {Graph, GraphEdge, GraphNode, Points, constructMCS} from "./index";

And you're good to go.

Usage

See the two examples in the ./examples folder. They are meant to be an introduction on how to use this algorithm.

Online examples

Check out these two working examples on codepen:

NB: these online examples allow you to see the output very well but are not the best option if you want to understand how to use the algorithm yourself. For that I recommend taking a look at the ./examples folder. That's because on codepen I had to squeeze all the modules into one file, thereby making it less clear.

Some details about the coding style and performance

The algorithm is written in pure functional programming style. As such it makes heavy use of recursion. However it is designed such that javascript interpreter can perform tail-call optimization (all recursive calls are at the last statement of the function) in order to prevent a maximum calls stack exceeded error. That said I still have to test the algorithm for graphs with >23 nodes.

Some more details about the maximum common subgraph problem

Given two graphs, mcs is the largest graph which is structurally identical to both graphs. Constructing the mcs is fundamental in order to compute the similarity between two graphs. Indeed this correlation is a value between 0 and 1 which results from the comparison between the size of the mcs and the averaged size of the two original graphs. I'll write a more detailed mathematical explanation soon.

Future projects

  • Create a python version of this algorithm.

Built with

Acknowledgements

Moritz F. Wurm, Ph.D. was the who kick-started this project. He has also given me fundamental feedback throughout the development of this algorithm during an internship I have done at his lab. For more details about the reason why this algorithm was created in the first place check out the readme of this example.

mcs's People

Contributors

salamanderxing avatar

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.