GraphStream Users

Archives de la liste Aide


Re: Adjacency Matrix


Chronologique Discussions 
  • From: Yoann Pigné <yoann.pigne AT gmail.com>
  • To: "graphstream-users AT litislab.fr" <graphstream-users AT litislab.fr>, Suhas Bhairav <suhasbhairav AT gmail.com>
  • Subject: Re: Adjacency Matrix
  • Date: Thu, 11 Aug 2016 10:47:22 +0200

Hi,

You can access graphs’ nodes with indices, so it becomes trivial to create a
graph from such matrix or create a matrix from a graph.

From the the "Getting Started" tutorial (first link in google when looking
for « graphstream adjacency matrix ») :

int n = graph.getNodeCount();
byte adjacencyMatrix[][] = new byte[n][n];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
adjacencyMatrix[i][j] = graph.getNode(i).hasEdgeBetween(j) ?
1 : 0;


Yoann

> On Aug 11, 2016, at 10:18 AM, Suhas Bhairav
> <suhasbhairav AT gmail.com>
> wrote:
>
> Hi All,
>
> Is there an adjacency matrix feature in graphstream with respect to graphs?
>
> Regards
> Suhas Bhairav




Archives gérées par MHonArc 2.6.16.

Top of page