Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.37 KB | None | 0 0
  1. nx::Class create EdgeGraphPrinted -superclass EdgeList_Graph {
  2.         :public method dot_print {} {
  3.            
  4.             if {${directed}} {
  5.                 append collections "digraph {\n"
  6.                
  7.                 if {{$weighed}} {
  8.                     foreach edge ${:edges} {
  9.                         append collections "\t"
  10.                         append collections "[string trim [$edge cget -a] "::nsf::__#"] -> [string trim [$edge cget -b] "::nsf::__#"]"
  11.                         append collections "\t"
  12.                         append collections "\n"
  13.                     }
  14.                 } else {
  15.                     foreach edge ${:edges} {
  16.                         append collections "\t"
  17.                         append collections "[string trim [$edge cget -a] "::nsf::__#"] -> [string trim [$edge cget -b] "::nsf::__#"]"
  18.                         append collections "\t"
  19.                         append collections "\n"
  20.                     }
  21.                 }
  22.                
  23.             } else {
  24.                 append collections "graph {\n"
  25.                
  26.                 if {{$weighed}} {
  27.                     foreach edge ${:edges} {
  28.                         append collections "\t"
  29.                         append collections "[string trim [$edge cget -a] "::nsf::__#"] -- [string trim [$edge cget -b] "::nsf::__#"]"
  30.                         append collections "\t"
  31.                         append collections "\n"
  32.                     }
  33.                 } else {
  34.                     foreach edge ${:edges} {
  35.                         append collections "\t"
  36.                         append collections "[string trim [$edge cget -a] "::nsf::__#"] -- [string trim [$edge cget -b] "::nsf::__#"]"
  37.                         append collections "\t"
  38.                         append collections "\n"
  39.                     }
  40.                 }
  41.             }
  42.            
  43.             append collections "\}"
  44.             puts $collections
  45.             return $collections
  46.         }
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement