File: connected_links.sci

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 (30 lines) | stat: -rw-r--r-- 966 bytes parent folder | download | duplicates (2)
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
function connected=connected_links(scs_m,k)
//given a link number returns all links connected with him through split
// Copyright INRIA
TYPE_OBJET=1;GRAPHIQUE=2;
OBJET_ORIGINE=8;OBJET_DESTINATION=9
$ENTREES=5;$SORTIES=6;$ENTREES_EVT=7;$SORTIES_EVT=8

if scs_m(k)(TYPE_OBJET)<>'Link' then
  error('Object is not a link')
end
connected = []
liaisons_a_traiter = k
    
//- Look for connected links
while liaisons_a_traiter <> []
  numero_liaison = liaisons_a_traiter(1)
  connected = [connected, numero_liaison]
  bloc_amont = scs_m(scs_m(numero_liaison)(OBJET_ORIGINE)(1))
  bloc_aval = scs_m(scs_m(numero_liaison)(OBJET_DESTINATION)(1))
  for bloc = list(bloc_amont, bloc_aval)
    if is_split(bloc) then
      for port = [$ENTREES, $SORTIES, $ENTREES_EVT, $SORTIES_EVT]
	liaisons_a_traiter = [liaisons_a_traiter; bloc(GRAPHIQUE)(port)]
      end
    end
  end
  for i = connected
    liaisons_a_traiter = liaisons_a_traiter(find(liaisons_a_traiter <> i))
  end
end