igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] plot VertexClustering help


From: Frederik Elwert
Subject: Re: [igraph] plot VertexClustering help
Date: Tue, 03 Dec 2013 10:59:23 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1

Hello Strong,

if I understood you correctly, you want to have a graph layout that
separates your clusters more visibly?

I did this by calculating a two-level layout: I first calculated the
layout of the contracted community graph in order to find a place for
each community, and then I calculated the layout for the original graph
in a way that places each community according to the first layout.

In my case, g1 is the contracted graph, while g2 is the original graph.
This is my solution in R, but it should be doable in Python along
similar lines:

# Layout for community graph
outer.layout <- layout.auto(g1) * vcount(g1)
# Create empty layout for orignal graph
inner.layout <- matrix(nrow=vcount(g2), ncol=2)
r <- 2.9
for (comm in 1:length(contracted.community)) {
  # IDs of community members in outer graph
  vids <- which(membership(contracted.community) == comm)
  # calculate layout for community
  comm.graph <- induced.subgraph(g2, vids)
  comm.layout <- layout.auto(comm.graph)
  # normalize community layout into corresponding outer graph vertex
  bbox <- outer.layout[comm,] + c(-r, -r, r, r)
  comm.layout <- layout.norm(comm.layout, xmin=bbox[1], ymin=bbox[2],
                             xmax=bbox[3], ymax=bbox[4])
  inner.layout[vids,] <- comm.layout
}

plot(contracted.community, g2, layout=inner.layout,
     edge.color=c("black", "gray")[crossing(contracted.community,
                                            g2)+1])


Frederik



Am 03.12.2013 09:04, schrieb lovelose:
> Hi everyone,
> I have just started out with igraph in the Python interface. I want to
> plot the VertexClustering which different communities are separated. I
> have run the simple code below:
>       
>       from igraph import *
>       g=Graph.Barabasi(300,5)
>       g1=Graph.commuity_walktrap(g)
>       g2=VertexDendrogram.as_clustering(g1)
>       plot(g2)
> 
> The problem now is that the result is different communities are mixed
> together in a picture and I can't figure out single one community directly. 
> 
> Is there some function can separate different communities (such as,
> community1 is on the left side and community2 is on the right side) , or
> do I have to redraw the network?
> I have found the function cluster_graph(), but it contracts each
> community into a vertex. The connections inside a community are  invisible.
> Thank you.
> 
> Regards,
> Strong
> 
> 
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]