Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Produces a low-dimensional representation of the input graph

Project description

Produces a low-dimensional representation of the input graph.

Calculates the ECTD [1] of the graph and reduces its dimension using PCA. The result is an embedding of the graph nodes as vectors in a low-dimensional space.

Graph data in this repository is courtesy of the mind-blowingly cool University of Florida Sparse Matrix Collection.


Draw a graph, including edges, from a mat file

>>> import
>>> import networkx as nx
>>> import graphpca
>>> mat ='test/bcspwr01.mat')
>>> A = mat['Problem'][0][0][1].todense()  # that's just how the file came
>>> G = nx.from_numpy_matrix(A)
>>> graphpca.draw_graph(G)

Get a 2D PCA of a high-dimensional graph and plot it.

>>> import networkx as nx
>>> import graphpca
>>> g = nx.erdos_renyi_graph(1000, 0.2)
>>> g_2 = graphpca.reduce_graph(g, 2)
>>> graphca.plot_2d(g_2)


Feel free to fork me and create a pull request at


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for graphpca, version 0.5
Filename, size File type Python version Upload date Hashes
Filename, size graphpca-0.5.tar.gz (6.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page