Skip to main content

DOI

GraphLearn

Learn how to construct graphs given representative examples.

Discriminative systems that can deal with graphs in input are known, however, generative or constructive approaches that can sample graphs from empirical distributions are less developed. This is a Metropolis–Hastings approach that uses a novel type of graph grammar to efficiently learn proposal distributions in a data driven fashion.

References

Costa, Fabrizio. "Learning an efficient constructive sampler for graphs." Artificial Intelligence (2016). link

Python3

This demonstrates the grammar which is the heart of graphlearn. Sampling as in the py2 example is demonstrated in graphlearn/sample.py.

from graphlearn.local_substitution_graph_grammar import LocalSubstitutionGraphGrammar
from graphlearn.util import util
import structout as so

# get graphs
gr = util.get_cyclegraphs()

#  induce a grammar, pick a graph, and apply all possible substitutions
mylsgg = LocalSubstitutionGraphGrammar()
mylsgg.fit(gr)
graphs =  list(mylsgg.neighbors(gr[0]))
so.gprint(graphs)

''

Python2

# set up graph source

from eden.io.gspan import gspan_to_eden
from itertools import islice
def get_graphs(dataset_fname='../../toolsdata/bursi.pos.gspan', size=100):
    return  islice(gspan_to_eden(dataset_fname),size)
    
# sample some graphs

from graphlearn.graphlearn import  Sampler
sampler=Sampler(n_steps=50)
samples = sampler.fit_transform(get_graphs())

# draw result

from graphlearn.utils import draw
for i in range(5):
        draw.graphlearn(samples.next())

''

Install (Py2)

We only maintain the python3 version at this point. an outdated but detailed installation guide for the python2 version is available here.

Examples (py2)

See here for more examples. Examples still use python2...

Release files for graphlearn 0.0.934

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for graphlearn 0.0.934
File Size Uploaded
graphlearn-0.0.934.tar.gz 21.4 kB Details

Release files / graphlearn-0.0.934.tar.gz

Download URL graphlearn-0.0.934.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a4d61dec148167df57e416e40779571d7261c6a0e26285829cd36abdf4067251
BLAKE2b-256 checksum
How to use checksums
6cf1384b8f5d9126fca52e8ce29d6addee2c00b3212dcb8e3baaa946bdcfede5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.0.934 This release

1 release file

0.0.932

1 release file

0.0.928

1 release file

0.0.817

1 release file

0.0.816

1 release file

0.0.815

1 release file

0.0.813

1 release file

0.0.811

1 release file

0.0.809

1 release file

0.0.792

1 release file

0.0.770

1 release file

0.0.686

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page