Changeset 16df684 in git


Ignore:
Timestamp:
Nov 4, 2017, 4:32:48 PM (6 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
7aa8ebd3a7ec021c4a466cfa15b50b7fc4daa44d
Parents:
5a5ef881f3af1708074c5c01b7add74757de7ef3
Message:
Fix existsRoute() to require at least one edge
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/fpadim.lib

    r5a5ef88 r16df684  
    12151215"USAGE: existsRoute(G,v,u); G a graph, v and u vertices
    12161216NOTE: don't pass anything to # (internal use for recursion)
    1217 "
    1218 {
    1219   if (v == u) {return (1);}
    1220 
     1217@*    routes always have at least one edge
     1218"
     1219{
    12211220  int n = ncols(G);
    12221221
     
    12241223  intvec visited;
    12251224  if (size(#) > 0) {
     1225    if (v == u) {return (1);} // don't check on first call so |route| >= 1 holds
    12261226    visited = #[1];
    1227   } else {
     1227  } else { // first call
    12281228    visited[n] = 0;
    12291229  }
     
    12341234  // recursive DFS
    12351235  for (int i = 1; i <= n; i++) {
    1236     if (G[v,i] && !visited[i]) {
     1236    if (G[v,i] && (!visited[i] || i == u)) { // i == u to allow routes from u to u
    12371237      if (existsRoute(G, i, u, visited)) {
    12381238        return (1);
Note: See TracChangeset for help on using the changeset viewer.