File: add_edge.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 (43 lines) | stat: -rw-r--r-- 1,588 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
function [g1]=add_edge(i,j,g)
// Copyright INRIA
[lhs,rhs]=argn(0)
if rhs<>3 then error(39), end
n=g('node_number')
ma=prod(size(g('tail')))
// check i and j
if prod(size(i))<>1 then
  error('First argument must be a scalar')
end
if (i<1|i>n) then
  error(string(i)+' is not a node number')
end
if prod(size(j))<>1 then
  error('Second argument must be a scalar')
end
if (j<1|j>n) then
  error(string(j)+' is not a node number')
end
// adding an edge from node i to node j
g1=g;
g1('tail')=[g('tail') i]; g1('head')=[g('head') j];
if g('edge_name')<>[] then g1('edge_name')=[g('edge_name') string(ma+1)];end;
if g('edge_color')<>[] then g1('edge_color')=[g('edge_color') 0];end;
if g('edge_width')<>[] then
  g1('edge_width')=[g('edge_width') g('default_edge_width')];
end;
if g('edge_hi_width')<>[] then
  g1('edge_hi_width')=[g('edge_hi_width') g('default_edge_hi_width')];
end;
if g('edge_font_size')<>[] then
  g1('edge_font_size')=[g('edge_font_size') g('default_font_size')];
end;
if g('edge_length')<>[] then g1('edge_length')=[g('edge_length') 0];end;
if g('edge_cost')<>[] then g1('edge_cost')=[g('edge_cost') 0];end;
if g('edge_min_cap')<>[] then g1('edge_min_cap')=[g('edge_min_cap') 0];end;
if g('edge_max_cap')<>[] then g1('edge_max_cap')=[g('edge_max_cap') 0];end;
if g('edge_q_weight')<>[] then g1('edge_q_weight')=[g('edge_q_weight') 0];end;
if g('edge_q_orig')<>[] then g1('edge_q_orig')=[g('edge_q_orig') 0];end;
if g('edge_weight')<>[] then g1('edge_weight')=[g('edge_weight') 0];end;
if g('edge_label')<>[] then
  g1('edge_label')=[g('edge_label') string(ma+1)];
end;