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

Metadata

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 Provenance
graphlearn-0.0.934.tar.gz 21.4 kB Without provenance 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

Security for graphlearn 0.0.934

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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