I am trying to do some spectral clustering on a digraph, specifically, the digraph corresponding to C Elegans Adult Male, using the edge list available at wormwiring.org. I downloaded the csv file as column vectors, VarName1 (categorical array of the start node of an edge), VarName2 (categorical array of the end node of the edge), VarName3 (double array of the weight of the edge), and VarName4 (categorical array of the type of connection, chemical or electrical). All are of size 5107 x 1. For the moment, I am ignoring VarName4. As an example, here are the first 10 entries of VarName1-3:
>> [VarName1(1:5) VarName2(1:5)]
ans =
5×2 categorical array
I1L I2L
I1L I3
I1L I5
I1L I6
I1L M2L
>> VarName3(1:5)
ans =
10
3
2
1
3
I would like to construct a digraph from this data where the nodes are labeled as I1L, I2L, I3, etc. I tried
>> G = digraph(VarName1, VarName2, VarName3)
which spits out
Error using matlab.internal.graph.constructFromEdgeList (line 98)
Node IDs must both be numeric or both be character vectors.
Error in digraph (line 273)
matlab.internal.graph.constructFromEdgeList( …
As a next step, I extracted the unique node labels as
>> UniqueLabels = unique([unique(VarName1); unique(VarName2)])
which is a categorical array of size 526 x 1, and then tried
>> G = digraph(VarName1, VarName2, VarName3, UniqueLabels)
which spits out
Error using matlab.internal.graph.constructFromEdgeList (line 62)
Node information must be a cell array of character vectors, a table, or a number of nodes.
Error in digraph (line 273)
matlab.internal.graph.constructFromEdgeList( …
I would very much appreciate any ideas/suggestions that you might be able to provide. Thank you.
— Kamal
Best Answer