Skip to content

Commit

Permalink
Update README.md (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
j6k4m8 authored Oct 1, 2020
1 parent b134778 commit 04936ff
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,10 @@ Subgraph isomorphism is a resource-heavy (but branch-parallelizable) algorithm t

_Grand-Iso_ is a subgraph isomorphism algorithm that exchanges this resource-limitation for a parallelizable partial-match queue structure.

## Pseudocode for "Grand-Iso" algorithm

```
- Accept a motif M, and a host graph H.
- Create an empty list for result storage, R.
- Create an empty queue, Q.
- Preprocessing
- Identify the most "interesting" node in motif M, m1.
- Add to Q a set of mappings with a single node, with one map for all
nodes in H that satisfy the requirements of m1: degree, attributes, etc
- Motif Search
- "Pop" a backbone B from Q
- Identify as m1 the most interesting node in motif M that does not yet
have a mapping assigned in B.
- Identify all nodes that are valid mappings from the backbone to m1,
based upon degree, attributes, etc.
- If multiple nodes are valid candidates, add each new backbone to Q.
- Otherwise, when all nodes in M have a valid mapping in B to H, add
the mapping to the results set R.
- Continue while there are still backbones in Q.
- Reporting
- Return the set R to the user.
```

## Example Usage

```python
from grandiso import find_motifs
import networkx as nx

host = nx.fast_gnp_random_graph(10, 0.5)
Expand All @@ -47,6 +24,7 @@ len(find_motifs(motif, host))
Directed graph support:

```python
from grandiso import find_motifs
import networkx as nx

host = nx.fast_gnp_random_graph(10, 0.5, directed=True)
Expand All @@ -59,3 +37,31 @@ motif.add_edge("D", "A")

len(find_motifs(motif, host))
```

## Counts-only

For very large graphs, you may use a good chunk of RAM not only on the queue of hypotheses, but also on the list of results. If all you care about is the NUMBER of results, you should pass `count_only=True` to the `find_motifs` function. This will dramatically reduce your RAM overhead on higher-count queries.

## Pseudocode for "Grand-Iso" algorithm

```
- Accept a motif M, and a host graph H.
- Create an empty list for result storage, R.
- Create an empty queue, Q.
- Preprocessing
- Identify the most "interesting" node in motif M, m1.
- Add to Q a set of mappings with a single node, with one map for all
nodes in H that satisfy the requirements of m1: degree, attributes, etc
- Motif Search
- "Pop" a backbone B from Q
- Identify as m1 the most interesting node in motif M that does not yet
have a mapping assigned in B.
- Identify all nodes that are valid mappings from the backbone to m1,
based upon degree, attributes, etc.
- If multiple nodes are valid candidates, add each new backbone to Q.
- Otherwise, when all nodes in M have a valid mapping in B to H, add
the mapping to the results set R.
- Continue while there are still backbones in Q.
- Reporting
- Return the set R to the user.
```

0 comments on commit 04936ff

Please sign in to comment.