File: graph_simp.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 (35 lines) | stat: -rw-r--r-- 900 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
function [g1]=graph_simp(g)
// Copyright INRIA
[lhs,rhs]=argn(0)
if rhs<>1 then error(39), end
// check g
check_graph(g)
n=g('node_number');
ta=g('tail');he=g('head');
[ir ic]=find(ta==he);
ta(ic)=[];he(ic)=[];
p=round(log(n)/log(10));q=10^(p+4);
w=ta'*q+he';[w1 iw]=sort(w);
ww=w1(2:$)-w1(1:($-1));
[ir ic]=find(ww==0);
index=iw(ir);
ta(index)=[];he(index)=[];
spg=sparse([ta' he'],ones(size(ta,2),1),[n n]);
spg=spg+spg';
[ir ic]=find(spg==2);kk=[ir' ic'];
spg1=[];
if (kk <> []) then
  spg1=sparse(kk,ones(1,(size(ir,2))),[n n]);
end;
spg=spg-spg1;
spg=tril(spg,-1);
[ij,v,mn]=spget(spg);
g1=make_graph('foo',0,n,ij(:,1)',ij(:,2)');
g1('node_type')=g('node_type');
g1('node_x')=g('node_x');
g1('node_y')=g('node_y');
g1('node_color')=g('node_color');
g1('node_diam')=g('node_diam');
g1('node_border')=g('node_border');
g1('node_font_size')=g('node_font_size');
g1('node_demand')=g('node_demand');