I'm using Mathematica 10, but I'm having a hard time getting it to do anything useful for network analysis because I'm having a hard time working with node properties and analyzing the graph by its node properties...or even coloring the nodes according the properties.
To start, given the way I'm currently assigning the properties to the nodes (vertices), they do not persist when I take a subgraph of the original graph to which I've assigned the properties. For example:
SomeGraph = Graph[{1 <-> 2, 2 <-> 3, 3 <-> 1}, Properties -> {1 -> "happiness" -> 1.1},
2 -> {"happiness" -> 1.5}, 3 -> {"happiness" -> 2.1}}];
PropertyList[{SomeGraph, 1}]
PartOfGraph = Subgraph[SomeGraph, {1, 2}];
PropertyList[{PartOfGraph, 1}]
I would expect the Subgraph function to preserve the node properties, but the output is:
{"happiness", VertexCoordinates, VertexShape, VertexShapeFunction, VertexSize, VertexStyle}
{VertexCoordinates, VertexShapeFunction, VertexShape, VertexSize, VertexStyle}
This makes me think there is a better way to assign the properties so they will be persistent through the subgraph function. For example, if I build a network from an adjacency list and a node attribute list, and then I want to isolate the largest connected component and color code by the attributes of the remaining nodes, I can't do it. And the first reason I can't is that once I isolate the largest connected component, the nodes no longer have the attributes I want to color by. Is there a different way to assign the properties to the vertices so that they don't disappear when I take subgraph?
The second problem is how to color and/or resize the nodes by the value of some property they have. For coloring I'm doing the following with GraphPlot:
TheProperties = Table[PropertyValue[{SomeGraph, i}, "happiness"],
{i, 1,Length[VertexList[SomeGraph]]}]
GraphPlot[SomeGraph, VertexRenderingFunction ->
({ColorData["Rainbow"][Rescale[TheProperties][[#2]]], Disk[#1, 0.05]} &)]
And that works despite being rather cumbersome. Is that the best way to achieve this effect? Among the vertex properties I wish to include is the x,y coordinates for the nodes to feed into GraphPlot's VertexCoordinates, so using GraphPlot does seem to be the way to go. But let me know if there is a better way to achieve this.