szhorvat / IGraphM

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

Enhancing property preservation in `IGGraphEditor` #130

Open lichengzhang1 opened 1 year ago

lichengzhang1 commented 1 year ago

IGGraphEditor is one of my favorite functions. However, I've noticed that every time I make a change to the embedding and press shift-enter, many properties of the graph are lost, especially vertex and edge colors, as in the example below. I still want to retain all of its properties.

g=Graph[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27}, {UndirectedEdge[1, 2], UndirectedEdge[1, 3], UndirectedEdge[1, 4], UndirectedEdge[1, 5], UndirectedEdge[2, 3], UndirectedEdge[2, 5], UndirectedEdge[2, 6], UndirectedEdge[3, 7], UndirectedEdge[3, 8], UndirectedEdge[4, 8], UndirectedEdge[4, 9], UndirectedEdge[4, 10], UndirectedEdge[5, 10], UndirectedEdge[5, 11], UndirectedEdge[6, 7], UndirectedEdge[6, 11], UndirectedEdge[6, 12], UndirectedEdge[7, 13], UndirectedEdge[7, 14], UndirectedEdge[8, 14], UndirectedEdge[8, 15], UndirectedEdge[9, 15], UndirectedEdge[9, 16], UndirectedEdge[9, 17], UndirectedEdge[10, 17], UndirectedEdge[10, 18], UndirectedEdge[11, 12], UndirectedEdge[11, 18], UndirectedEdge[12, 13], UndirectedEdge[12, 19], UndirectedEdge[13, 20], UndirectedEdge[13, 21], UndirectedEdge[14, 15], UndirectedEdge[14, 21], UndirectedEdge[15, 22], UndirectedEdge[16, 22], UndirectedEdge[16, 23], UndirectedEdge[16, 24], UndirectedEdge[17, 24], UndirectedEdge[17, 25], UndirectedEdge[18, 19], UndirectedEdge[18, 25], UndirectedEdge[19, 20], UndirectedEdge[19, 25], UndirectedEdge[20, 26], UndirectedEdge[20, 27], UndirectedEdge[21, 22], UndirectedEdge[21, 27], UndirectedEdge[22, 27], UndirectedEdge[23, 24], UndirectedEdge[23, 26], UndirectedEdge[23, 27], UndirectedEdge[24, 26], UndirectedEdge[25, 26]}, {FormatType -> TraditionalForm, GraphHighlight -> {5, 2, UndirectedEdge[1, 5], UndirectedEdge[2, 5], UndirectedEdge[2, 3], 1, UndirectedEdge[1, 2], UndirectedEdge[1, 3], 3}, GraphHighlightStyle -> {"Thick"}, GraphLayout -> {"Dimension" -> 2}, ImageSize -> {250, 250}, PlotTheme -> "Monochrome", VertexCoordinates -> {{0.08151518540029386, -0.1293877040935608}, {0.16970562748477136, -0.2068847042669158}, {0.062225396744416295, -0.29621586095681585}, {0.026678836506319404, -0.0682025129591584}, {0.20364675298172596, -0.10388281647407512}, {0.23758787847868013, -0.29621586095681585}, {0.062225396744416295, -0.37541182044970894}, {-0.02975499687711458, -0.16081414610654554}, {-0.07606884525171817, 0.04129166045592244}, {0.1310240027538165, -0.02389986209244972}, {0.29415642097360395, -0.19439248446595292}, {0.3280975464705581, -0.37541182044970894}, {0.20025063166139284, -0.40313102960620717}, {-0.07637819439953812, -0.2439334406713187}, {-0.13068716097386865, -0.15522846361312903}, {-0.29344724948505, 0.2354108271760408}, {0.09318019294572664, 0.15318679121993634}, {0.27405292666255004, -0.06371055086132756}, {0.3969896128677325, -0.2179727362491378}, {0.7071067811865475, -0.7071067811865475}, {-0.23094523782294912, -0.4029072948986619}, {-0.34054660736710385, -0.2574579281305744}, {-0.7071067811865475, 0.7071067811865475}, {-0.05006676413483084, 0.45070279519226797}, {0.36783237841563915, 0.1446525713240046}, {0.7071067811865475, 0.7071067811865475}, {-0.7071067811865475, -0.7071067811865475}}, VertexSize -> {{0.02, 0.02}}, VertexStyle -> {GrayLevel[0.6]}}]
IGGraphEditor[g]

image

So it would be helpful to provide an option for this. By doing so, I won't have to go back and reapply properties every time I make adjustments.

szhorvat commented 1 year ago

It's great to hear that you are making good use of this function!

This is a reasonable feature request that we will look into.

kubaPod commented 1 year ago

@lichengzhang1 I am happy you find it useful. The next update, I will do my best to be in October, will come with that.

kubaPod commented 1 year ago

@lichengzhang1 @szhorvat I can't promise GraphHighlight will end up high on a todo list but other than that here's a small teaser for styles:

graph = Graph[
     {1, Style[2, Red], 3}, 
     { 1 -> 2, Style[2 -> 3, Orange], 3 -> 1},
     VertexStyle         -> Blue,
     EdgeStyle           -> {(1 -> 2) -> Dashed}(*,  
     GraphHighlight      -> {3, 3->1},
     GraphHighlightStyle -> {"Thick"}*)
   ];

{graph, IGGraphEditor @ graph}

image

image

lichengzhang1 commented 3 months ago

Nice. By the way, will the new version of IGraphM be released this year?