File: trans_closure.cat

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (37 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37

trans_closure(1)               Scilab function               trans_closure(1)
NAME
  trans_closure - transitive closure

CALLING SEQUENCE
  g1 = trans_closure(g)

PARAMETERS

  g : graph list

  g1 : graph list

DESCRIPTION
  trans_closure returns as a new graph list g1 the transitive closure of the
  graph g. This graph must be directed and connected.  If <name> if the name
  of graph g, <name>_trans_closure is the name of the transitive closure.

EXAMPLE
  ta=[2 3 3 5 3 4 4 5 8];
  he=[1 2 4 2 6 6 7 7 4];
  g=make_graph('foo',1,8,ta,he);
  g('node_x')=[129 200 283 281 128 366 122 333];
  g('node_y')=[61 125 129 189 173 135 236 249];
  show_graph(g);
  g1=trans_closure(g);
  vv=1*ones(ta); aa=sparse([ta' he'],vv');
  ta1=g1('tail'); he1=g1('head');
  ww=1*ones(ta1); bb=sparse([ta1' he1'],ww');
  dif=bb-aa; lim=size(ta1); edgecolor=0*ones(ta1);
  for i=1:lim(2)
   if dif(ta1(i),he1(i))==1 then edgecolor(i)=11; end;
  end;
  g1('edge_color')=edgecolor;
  x_message('Transitive closure of the graph');
  show_graph(g1);