Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
j6k4m8 authored Mar 18, 2021
1 parent 6e52a51 commit 791883b
Showing 1 changed file with 1 addition and 65 deletions.
66 changes: 1 addition & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,72 +54,8 @@ len(find_motifs(motif, host))

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.

## All Arguments to `find_motifs`
There are many other arguments that you can pass to the motif search algorithm. For a full list, see [here](https://github.com/aplbrain/grandiso-networkx/wiki/Algorithm-Arguments).

| Argument | Type | Default | Description |
| ------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `motif` | `nx.Graph` | | The motif to search for. Either a `nx.Graph` or `nx.DiGraph`. You can also pass something `networkx.Graph`-flavored, like a [grand.Graph](https://github.com/aplbrain/grand). |
| `host` | `nx.Graph` | | The "haystack" graph to search within. Either a `nx.Graph` or `nx.DiGraph`. You can also pass something `networkx.Graph`-flavored, like a [grand.Graph](https://github.com/aplbrain/grand). |
| `interestingness` | `dict` | `None` | A lookup dictionary that assigns a floating number between 0 and 1 to each node in the `motif` graph. Nodes with values closest to 1 will be preferred when the candidate-mapper advances the exploration front. If this doesn't make sense to you, you can ignore this argument entirely. If none is provided, this will default to a uniform interestness metric where all nodes are considered equally. |
| `count_only` | `bool` | `False` | Whether to return only a count of motifs, rather than a list of mappings. If you set this to `True`, you will get back an integer result, not a list of dicts. |
| `directed` | `bool` | `None` | Whether to enforce a directed/undirected search. True means enforce directivity; False means enforce undirected search. The default (None) will guess based upon your motif and host. |
| `profile` | `bool` | `False` | Whether to slow down execution but give you a better idea of where your RAM usage is going. This is better ignored unless you're debugging something particularly nuanced. |
| `isomorphisms_only` | `bool` | `False` | Whether to search only for isomorphisms. In other words, whether to search for edges that exist in the node-induced subgraph. |
| `hints` | `List[Dict[Hashable, Hashable]]` | `None` | A list of valid candidate mappings to use as the starting seeds for new maps. See _Using Hints_, below. |
| `limit` | `int` | `None` | An optional integer limit of results to return. If the limit is reached, the search will return early. |

## Using Hints

GrandIso optionally accepts an argument `hints` which is a list of valid partial mappings to use to seed the search. For example, in this code:

```python
host = nx.DiGraph()
nx.add_path(host, ["A", "B", "C", "A"])
motif = nx.DiGraph()
nx.add_path(motif, ["a", "b", "c", "a"])

find_motifs(motif, host)
```

There are three valid mappings (because each of `A`, `B`, and `C` can map to `a`, `b`, or `c`).

We can declare that node `A` maps to node `a` or `b` like this:

```python
host = nx.DiGraph()
nx.add_path(host, ["A", "B", "C", "A"])
motif = nx.DiGraph()
nx.add_path(motif, ["a", "b", "c", "a"])

find_motifs(
motif, host,
hints=[{"A": "a"}, {"A", "b"}]
)
```

## 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.
```

## Hacking on this repo

Expand Down

0 comments on commit 791883b

Please sign in to comment.