[codeface] [PATCH 2/8] Scale edge weight before generating dot files

  • From: Mitchell Joblin <joblin.m@xxxxxxxxx>
  • To: codeface@xxxxxxxxxxxxx
  • Date: Sat, 31 May 2014 12:39:29 +0200

- Graphviz breaks when the edge weights are extremely high

Signed-off-by: Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx>
---
 codeface/R/cluster/persons.r | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/codeface/R/cluster/persons.r b/codeface/R/cluster/persons.r
index de308ed..f7305d4 100755
--- a/codeface/R/cluster/persons.r
+++ b/codeface/R/cluster/persons.r
@@ -688,7 +688,12 @@ save.group <- function(conf, .tags, .iddb, idx, .prank, 
.filename=NULL, label) {
   }
 
   if (!is.null(.filename)) {
-    write.graph(g, .filename, format="dot")
+    ## Scale edge weights, extremely large weights will cause graphviz to
+    ## fail during rendering
+    g.scaled <- g
+    E(g.scaled)$weights <- scale.data(log(E(g.scaled)$weights + 1), 0, 100)
+    
+    write.graph(g.scaled, .filename, format="dot")
   }
 
   return(g)
-- 
1.8.3.2


Other related posts:

  • » [codeface] [PATCH 2/8] Scale edge weight before generating dot files - Mitchell Joblin