File: delete_arcs.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 (59 lines) | stat: -rw-r--r-- 1,748 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
47
48
49
50
51
52
53
54
55
56
57
58
59
function [g1]=delete_arcs(ij,g)
// Copyright INRIA
[lhs,rhs]=argn(0)
if rhs<>2 then error(39), end
// checking ij
if (ij==[]) then g1=g; return end;
if (type(ij)<>1|size(ij,2) <> 2) then
  error('First argument must be a n x 2 scalar vector')
end;
// deleting the edges from nodes i to nodes j
g1=g;ma=prod(size(g('tail')));n=g('node_number');
ta=g('tail');he=g('head');
ic=[];
//
if(g('directed') == 1) then
  for jj=1:size(ij,1),
    i=ij(jj,1);j=ij(jj,2);
    if ((i < 1)|(i > n)) then
      error(string(i)+' is not a node number')
    end;
    if ((j < 1)|(j > n)) then
      error(string(j)+' is not a node number')
    end;
    ic1=find((ta==i)&(he==j));ic=[ic ic1];
  end;
else
  for jj=1:size(ij,1),
    i=ij(jj,1);j=ij(jj,2);
    if ((i < 1)|(i > n)) then
      error(string(i)+' is not a node number')
    end;
    if ((j < 1)|(j > n)) then
      error(string(j)+' is not a node number')
    end;
    ic1=find((ta==i)&(he==j));ic=[ic ic1];
    ic1=find((ta==j)&(he==i));ic=[ic ic1];    
  end;
end;
//
ii=[1:ma];ii(ic)=[];
ta(ic)=[];
if ta==[] then
  error('Cannot delete, a graph must have at least one edge')
end;
g1('tail')=ta;
a=g('head');g1('head')=a(ii);
a=g('edge_name');g1('edge_name')=a(ii);
a=g('edge_color');g1('edge_color')=a(ii);
a=g('edge_width');g1('edge_width')=a(ii);
a=g('edge_hi_width');g1('edge_hi_width')=a(ii);
a=g('edge_font_size');g1('edge_font_size')=a(ii);
a=g('edge_length');g1('edge_length')=a(ii);
a=g('edge_cost');g1('edge_cost')=a(ii);
a=g('edge_min_cap');g1('edge_min_cap')=a(ii);
a=g('edge_max_cap');g1('edge_max_cap')=a(ii);
a=g('edge_q_weight');g1('edge_q_weight')=a(ii);
a=g('edge_q_orig');g1('edge_q_orig')=a(ii);
a=g('edge_weight');g1('edge_weight')=a(ii);
a=g('edge_label');g1('edge_label')=a(ii);