External node color in Gephi - graph

I'm trying to create a graph in Gephi. This graph is undirected and has over 100 nodes. I would like to color the nodes in this graph according to my convenience. Say I'd like to color the nodes in 9 different colors. For doing this, I downloaded a plugin to Gephi which may be found here.
Though the plugin works, I still have to go and enter the color value for every single node manually. There doesn't seem to be a way to do this programatically. And I'd have to create about 10 such graphs, so that means a lot of manual labor.
Can someone help me out with this problem? Does someone know a better way to have custom colors for each node generated programatically? At this point, I'm generating a .gdf file, the format looks something like this.
I also know that Gephi is quite buggy, is there any other graph visualization software that I can use? Out of the other usual things that one does to the graph, I definitely want the capability to set edge weights. In other words, I'd like to make the edges thicker if the edge weight is more and vice-versa.
I can't use D3 coz I don't know Javascript. I looked into using GraphViz but it seems like it requires a lot of manual manipulation of the graph file. I'd like to have something that I'm able to generate programatically.

What seems to be working is to add a column named color VARCHAR where you add the color hex value prepended with the # sign and no quotes.
Example:
nodedef> name,label,color VARCHAR
a,"Apple",#00ffdd
b,"Banana",#00ddff
c,"Cherry",#dd00ff
d,"Did it!",#0012ca
e,"Ed 209",#121212
edgedef> node1,node2,weight
a,b,2
b,c,30
b,d,0.4
d,e,200
Edit:
For a more informed answer take a look at the Gephi documentation. The color values in the link are rgb triples but I tried with hex and it worked

Related

add legend to graph according to node colors using Rcy3

I'm an advanced R user, but have just started recently using Rcy3 to create better visualisations of my graphs.. problem is I don't know how to add a legend to my figure that would explain the coloring of my nodes.
You may want to look at the app "LegendCreator". It's sort of in the beta stage, but it can be useful particularly for gradient legends. It also supports automation, although generally, you'll want to manually position the legend.
-- scooter

Label individual points in Sage plot

This seems like a straightforward problem, yet I can't find a solution. In Sage, I've got about 30 sorted points for a scatter_plot, and I want to add the order position as a label. I know this is easy if I were working with a graph object, since I could use the vertex_labels option in plot. Is there a simple fix to get this to work for a scatter_plot, or would I need to do something like make the points vertices and keep track of the exact location of each point
Currently, you may have to use matplotlib directly or mess around with that method inside of Sage to get this. See here or here for some related questions.
I've opened Trac 20583 for this.

How to code edge attributes as vertex attributes using igraph in R

I am graphing a network and trying to color the vertices using non-overlapping attributes. I want my network diagram to be colored according to different attributes. In this example, if the first three letters of ID 2 are equal to U 50 or U 51, I want this to show up as red. I have 5 attributes I want this graph coded by and any observations that don't fall into one of the categories should be coded in a default color. In this way I will be able to see the intensity of these attributes and better communicate this to other people. So far, I have been unable to get the code to work using a variety of different coding methods. First I tried to create a new variable that assigned the correct attribute to each observation before converting it into an i graph object.
anon.nd$vertexcolor[substr(anon.nd$ID2,1,3)=="U50" | substr(anon.nd$ID2,1,3)=="U51"]<-"O"
anon.nd$vertexcolor[substr(anon.nd$ID2,1,3)=="U54" | substr(anon.nd$ID2,1,3)=="U55"]<-"P"
anon.nd$vertexcolor[anon.nd$INT.type=="K1"]<-"INT.NB"
anon.nd$vertexcolor[anon.nd$Country=="L12"]<-"UK"
anon.nd$vertexcolor[anon.nd$ID2=="U769"]<-"OBL"`
I then specified the colors I wanted to assign to each each attribute. I used the get vertex attribute code and filled in the appropriate colors.
anon.nd1<-graph.data.frame(anon.nd)
vertex_colors=get.vertex.attribute(anon.nd1,"vertexcolor")
colors=c('azure3', 'firebrick1', 'orange1', 'darkblue', 'darkolivegreen', 'gold')
vertex_colors[vertex_colors==0]=colors[1]
vertex_colors[vertex_colors==1]=colors[2]
vertex_colors[vertex_colors==2]=colors[3]
vertex_colors[vertex_colors==3]=colors[4]
vertex_colors[vertex_colors==4]=colors[5]
vertex_colors[vertex_colors==5]=colors[6]
I tried this same method using just:
vertex_colors<-vertex_colors+1
Then to plot, I changed my edge color to black, specified my layout, and change the size of my edges and vertices.
E(anon.nd1)$color="black"
nd.layout<-layout.fruchterman.reingold(anon.nd1)
plot(anon.nd1, layout=nd.layout, vertex.color=vertex_colors, vertex.size=2, edge.arrow.size=.01, vertex.label=NA)
Using this method, no color shows up on the vertices, not even the default color. Using a different method where I set the vertex attribute, I do a little better. The default color shows up, but the colors I want do not.
anon.nd2<-graph.data.frame(anon.nd)
V(anon.nd2)$colors<-"azure3"
V(anon.nd2)$colors[substr(anon.nd2$ID2,1,3)=="U50" | substr(anon.nd2$ID2,1,3)=="U51"]<-"firebrick1"
V(anon.nd2)$colors[substr(anon.nd2$ID2,1,3)=="U54" | substr(anon.nd2$ID2,1,3)=="U55"]<-"orange1"
V(anon.nd2)$colors[anon.nd2$Country=="L12"]<-"darkblue"
V(anon.nd2)$colors[anon.nd2$INT.type=="K1"]<-"darkolivegreen"
V(anon.nd2)$colors[anon.nd2$ID2=="U769"]<-"gold"
E(anon.nd2)$color<-"black"
nd.layout<-layout.fruchterman.reingold(anon.nd2)
windows(width=20, height=16)
plot(anon.nd2, layout=nd.layout, vertex.size=2, edge.arrow.size=.01, vertex.label=NA, vertex.color="vertex_colors")
I think the problem might be that I am trying to code vertex color using multiple (non-overlapping) edge attributes. But I don't know how to convert and edge attribute into a vertex attribute. I also don't know if there is some other, unidentified problem with my code.
Here is the link to my data is copied below as well as a link to my full code file which has one or two other methods I tried using to solve this problem. Any help would be much appreciated!
Data
And here is an R file with my code, which is also above: R-file
I think you are messing up your vertex_color vector, have a look at it with head().
anon.nd$vertexcolor[anon.nd$INT.type=="K1"]<-"INT.NB"
vertex_colors[vertex_colors==0]=colors[1]
You first assign a string and then compare with numbers, so non of them should be true.
plot(anon.nd2, layout=nd.layout, vertex.size=2, edge.arrow.size=.01, vertex.label=NA, vertex.color="vertex_colors")
This contains a typo and returns an error for me since "vertex_colors" isn't a colour name.
Last but not least, does
plot(anon.nd2, vertex.color=colors)
or
plot(anon.nd2, vertex.color=1:8)
result in a colourful plots? If yes, the vertex_colors vector is your problem, if not something else is.

visualization - size of circle proportionate to the value of the item

I'm getting familiar with Graphviz and wonder if it's doable to generate a diagram/graph like the one below (not sure what you call it). If not, does anyone know what's a good open source framework that does it? (pref, C++, Java or Python).
According to Many Eyes‌​, this is a bubble chart. They say:
It is especially useful for data sets with dozens to hundreds of values, or with values that differ by several orders of magnitude.
...
To see the exact value of a circle on the chart, move your mouse over it. If you are charting more than one dimension, use the menu to choose which dimension to show. If your data set has multiple numeric columns, you can choose which column to base the circle sizes on by using the menu at the bottom of the chart.
Thus, any presentation with a lot of bubbles in it (especially with many small bubbles) would have to be dynamic to respond to the mouse.
My usual practice with bubble charts is to show three or four variables (x, y and another variable through the size of the bubble, and perhaps another variable with the color or shading of the bubble). With animation, you can show development over time too - see GapMinder. FlowingData provides a good example with a tutorial on how to make static bubble charts in R.
In the example shown in the question, though, the bubbles appear to be located somewhat to have similar companies close together. Even then, the exact design criteria are unclear to me. For example, I'd have expected Volkswagen to be closer to General Motors than Pfizer is (if some measure of company similarity is used to place the bubbles), but that isn't so in this diagram.
You could use Graphviz to produce a static version of a bubble chart, but there would be quite a lot of work involved to do so. You would have to preprocess the data to calculate a similarity matrix, obtain edge weights from that matrix, assign colours and sizes to each bubble and then have the preprocessing script write the Graphviz file with all edges hidden and run the Graphviz file through neato to draw it.

How to draw a directed graph with labels on edges using quickgraph and graph# libraries?

I'm trying to draw a directed graph with labels on edges. I'm using graph# (graphsharp) and quickgraph, and I saw an explanation in the forums about how to add labels (it is not supported by the library), but cannot manage to implement myself. If someone could provide a working example using these two libraries I would be very thankful.
Update:
I'm now looking for something a little more complicated: My edges behave like nodes, they have connections to other nodes and have a name-tag. So they are like any other node, and when I draw the graph these edge-nodes must appear exactly in the middle of a certain connections. Any ideas?
Although it's not documented, QuickGraph supports output to other formats, like DGML. VS 2010 includes a very basic DGML viewer. It may be possible to output DGML so that the resulting graph has edge labels. However you will likely need to add support yourself.
Download the QuickGraph sources and play around with it. I'm a committer on the project, so if you figure it out let me know and we'll get your changes into the project.

Resources