szhorvat / IGraphM

IGraph/M is the igraph interface for Mathematica
http://szhorvat.net/mathematica/IGraphM
Other
91 stars 17 forks source link

Plotting communities while defining layouts like in Python #99

Closed Vurgit closed 4 years ago

Vurgit commented 4 years ago

Compared with python-igraph, igraphm can plot boundaries,but layoutsin Mathematica are not that nice. Once plotting communities, the layout of graphs will be lost and the edges and topology are not clear. When keeping the layout and plotting communities with different colors, the boundaries and edges between communities will vanish. Hoping to add a feature of plotting boundaries, keeping the layout of the graph and keeping the edges between communities at the mean time.

szhorvat commented 4 years ago

Would you mind posting a comparison screenshot to clarify what you mean exactly?

Vurgit commented 4 years ago

Are the screenshots visible? I met problems when uploading screenshots before. A typical python-igraph plot of communities is like this: Python-igraph communities plot Communities are plotted with different colors and layouts can be defined. In this picture the layout is defined as kawai_kamada. But no boundaries can be created. In igraphm, lets take examples in the documentation: igraphm communities plot There are boundaries but the layout is totally ruined. Layouts can only be plotted without partition of communities like this: igraphm layout plot The layout is nice but no communities or boundaries. Is there any solution to keep communities, layout and boundaries at the same time?

szhorvat commented 4 years ago

Note that CommunityGraphPlot is a visualization feature built-in to Mathematica. It is not provided by IGraph/M. It can merely be used to plot any community structure. It is also not the only way to visualize communities. If you want to colour vertices, you can use HighlightGraph, which is also a built-in function.

g = ExampleData[{"NetworkGraph", "FamilyGathering"}];

cl = IGCommunitiesMultilevel[g]

HighlightGraph[g, cl["Communities"], VertexSize -> Large]

image

Vurgit commented 4 years ago

Yes Mr Horvat thats a nicely plotted graph with communities, but I mean is it possible to add boundaries based on a graph like this in igraphm? There doesnt seem to be such features. Could that be added in the next version? 

------------------ 原始邮件 ------------------ 发件人: "Szabolcs Horvát"<notifications@github.com>; 发送时间: 2019年12月30日(星期一) 下午5:06 收件人: "szhorvat/IGraphM"<IGraphM@noreply.github.com>; 抄送: "yangyang"<980182570@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [szhorvat/IGraphM] Plotting communities while defining layouts like in Python (#99)

Note that CommunityGraphPlot is a visualization feature built-in to Mathematica. It is not provided by IGraph/M. It can merely be used to plot any community structure. It is also not the only way to visualize communities. If you want to colour vertices, you can use HighlightGraph, which is also a built-in function. g = ExampleData[{"NetworkGraph", "FamilyGathering"}]; cl = IGCommunitiesMultilevel[g] HighlightGraph[g, cl["Communities"], VertexSize -> Large]

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

szhorvat commented 4 years ago

I can see why that would be a desirable feature, but it is not obvious how to make it work well in practice. Depending on the graph layout, the vertices belonging to the same community may not be drawn contiguously in space.

Try re-evaluating this a few times after removing the SeedRandom command:

SeedRandom[12345];
g = RandomGraph[{50, 80}, VertexSize -> 1];
HighlightGraph[g, IGCommunitiesEdgeBetweenness[g]["Communities"]]

image

I am open to any suggestions on how to handle this in a general way.

szhorvat commented 4 years ago

A half-workaround with CommunityGraphPlot could be to disable edge bundling:

SeedRandom[12345];
g = RandomGraph[{50, 80}, VertexSize -> 1];
CommunityGraphPlot[g, IGCommunitiesEdgeBetweenness[g]["Communities"], 
 EdgeShapeFunction -> "Line"]

image

Vurgit commented 4 years ago

Oh thank you so much Dr Horvát thats exactly what I want

------------------ 原始邮件 ------------------ 发件人: "Szabolcs Horvát"<notifications@github.com>; 发送时间: 2019年12月30日(星期一) 晚上8:09 收件人: "szhorvat/IGraphM"<IGraphM@noreply.github.com>; 抄送: "yangyang"<980182570@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [szhorvat/IGraphM] Plotting communities while defining layouts like in Python (#99)

A half-workaround with CommunityGraphPlot could be to disable edge bundling: SeedRandom[12345]; g = RandomGraph[{50, 80}, VertexSize -> 1]; CommunityGraphPlot[g, IGCommunitiesEdgeBetweenness[g]["Communities"], EdgeShapeFunction -> "Line"]

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.