File: adj_lists.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 (46 lines) | stat: -rw-r--r-- 1,052 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function [lp,la,ls]=adj_lists(g,n,tail,head)
// Copyright INRIA
[lhs,rhs]=argn(0)
if rhs==1 then
  // g
  check_graph(g)
  directed=g('directed')
  n=g('node_number')
  tail=g('tail')
  head=g('head')
else
  if rhs<>4 then error(39), end
  directed=g
  // check directed
  if directed<>1&directed<>0 then
    error('First argument must be 0 or 1')
  end
  // check n
  if prod(size(n))<>1|n<1
    error('Second argument must be greater than 1')
  end
  // check tail
  s=size(tail)
  if s(1)<>1 then
    error('Third argument must be a row vector')
  end
  ma=s(2)
  // check head
  s=size(head)
  if s(1)<>1 then
    error('Fourth argument must be a row vector')
  end
  if s(2)<>ma then
    error('""tail"" and ""head"" must have identical sizes')
  end
  // check tail and head
  if min(min(tail),min(head))<1|max(max(tail),max(head))>n then
    error('""tail"" and ""head"" do not represent a graph')
  end
end
// compute lp, la and ls
if directed==1 then
  [lp,la,ls]=m6ta2lpd(tail,head,n+1,n)
else
  [lp,la,ls]=m6ta2lpu(tail,head,n+1,n,2*ma)
end