1

I want to plot a network in Python using a co-occurence matrix as an input, such that nodes that have a non-zero co-occurence count are connected, and the weight of the edges is proportional to the number of co-occurrences between each node.

Is there a python library in existence that will facilitate this task using a co-occurence matrix as an input?

yatu
  • 86,083
  • 12
  • 84
  • 139
RDG
  • 183
  • 3
  • 12

3 Answers3

2

You might find NetworkX to be a useful tool for that. You can easily feed it the input nodes and edges in several ways.

In the case that you want to generate your network using a co-occurrence matrix, you can use NetworkX's method from_numpy_matrix, which allows you to create a graph from a numpy matrix matrix which will be interpreted as an adjacency matrix.

Here's a simply toy example from the documentation:

import numpy as np
import networkx as nx

A=np.matrix([[1,1],[2,1]])
G=nx.from_numpy_matrix(A)
yatu
  • 86,083
  • 12
  • 84
  • 139
0

It is indeed possible to do something like that with networkx

Check this: https://stackoverflow.com/a/25651827/4288795

With it you can generate graphs like this:

enter image description here

Pedro Borges
  • 1,240
  • 10
  • 20
0

You can export the information to a graphml file format and use yEd Graph Editor to navigate and format the contents of your networkx graph.