File: contract_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 (23 lines) | stat: -rw-r--r-- 586 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
function [g1]=contract_edge(i,j,g)
// Copyright INRIA
[lhs,rhs]=argn(0)
if rhs<>3 then error(39), end
//contracting the edges between node i and node j
g1=delete_arcs([i j],g);
g1=delete_arcs([j i],g1);
ta=g1('tail');he=g1('head');
ii=find(ta==j);ta(ii)=i*ones(ii);
ii=find(he==j);he(ii)=i*ones(ii);
g1('tail')=ta;g1('head')=he;
xnodes=g('node_x');ynodes=g('node_y');
x1=xnodes(i);x2=xnodes(j);
y1=ynodes(i);y2=ynodes(j);
if (x1<>[]) then 
  xnodes(i)=0.5*(x1+x2);
  g1('node_x')=xnodes;
end;
if (y1<>[]) then
  ynodes(i)=0.5*(y1+y2);
  g1('node_y')=ynodes;
end;
g1=delete_nodes(j,g1);