Tk Library Source Code

Artifact [0505c85323]
Login

Artifact 0505c853236a684d4542ccb1e424e33ae6df1359:

Attachment "test.tcl" to ticket [1923685fff] added by petasis 2008-03-23 23:56:53.
cd [file dirname [info script]]
catch {console show}
#source C:/Users/petasis/Ellogon/ellogon2.0/lib_elep/ELEP_Structures/Graph/DGA.tcl
#source C:/Users/petasis/Ellogon/ellogon2.0/lib_elep/ELEP_Structures/Graph/ASDOTExporter.tcl
package require struct::graph
package require struct::prioqueue
## Load the graph...
set file [open abox_graph_struct.txt]
fconfigure $file -encoding utf-8
set data [read $file]
close $file
set graph graph
::struct::graph $graph deserialize $data
#ELEP::Structures::Graph::ASDOT::Exporter::write_dot graph.dot $graph
set nodes [lsort [$graph nodes]]
set arcs  [lsort [$graph arcs]]
set arcs_nu [llength $arcs]

set queue [::struct::prioqueue -real]

if {1} {
  foreach node $nodes {
    set degree(all) [$graph node degree $node]
    set degree(in)  [$graph node degree -in  $node]
    set degree(out) [$graph node degree -out $node]
    set ratio [expr {double($degree(out))/$arcs_nu}]
    set NODE2RATION($node) $ratio
    puts "$node : $degree(all) ($ratio)"
    puts "  -in  : $degree(in) ($arcs_nu)"
    puts "  -out : $degree(out) ($arcs_nu)"
    $queue put $node $ratio
  }
  while {[$queue size]} {
    set node [$queue get]
    if {$NODE2RATION($node) > 0} {
      puts " $node -> $NODE2RATION($node)"
      ## Get the in neihgbours...
      foreach one [$graph nodes -out $node] {
        puts "  -> $one"
      }
      foreach one [$graph nodes -in $node] {
        puts "  <- $one"
      }
    }
  }
}
exit