瀏覽代碼

netalib: minor updates

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@68031 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 9 年之前
父節點
當前提交
ef5c59412c
共有 4 個文件被更改,包括 14 次插入5 次删除
  1. 1 1
      lib/vector/neta/articulation_point.c
  2. 2 0
      lib/vector/neta/components.c
  3. 5 2
      lib/vector/neta/spanningtree.c
  4. 6 2
      lib/vector/neta/utils.c

+ 1 - 1
lib/vector/neta/articulation_point.c

@@ -3,7 +3,7 @@
 
    \brief Network Analysis library - connected components
 
-   Computes strongly and weakly connected components.
+   Computes network articulation points.
 
    (C) 2009-2010 by Daniel Bundala, and the GRASS Development Team
 

+ 2 - 0
lib/vector/neta/components.c

@@ -277,5 +277,7 @@ int NetA_strongly_connected_components(dglGraph_s * graph, int *component)
     dglNode_T_Release(&nt);
 
     G_free(stack);
+    G_free(order);
+    G_free(processed);
     return components;
 }

+ 5 - 2
lib/vector/neta/spanningtree.c

@@ -88,10 +88,12 @@ static int cmp_edge(const void *pa, const void *pb)
 int NetA_spanning_tree(dglGraph_s * graph, struct ilist *tree_list)
 {
     int nnodes, edges, nedges, i, index;
-    edge_cost_pair *perm;	/*permutaion of edges in ascending order */
+    edge_cost_pair *perm;	/*permutation of edges in ascending order */
     struct union_find uf;
     dglEdgesetTraverser_s et;
 
+    /* TODO: consider closed nodes / node costs */
+
     nnodes = dglGet_NodeCount(graph);
     nedges = dglGet_EdgeCount(graph);
     perm = (edge_cost_pair *) G_calloc(nedges, sizeof(edge_cost_pair));
@@ -99,7 +101,7 @@ int NetA_spanning_tree(dglGraph_s * graph, struct ilist *tree_list)
 	G_fatal_error(_("Out of memory"));
 	return -1;
     }
-    /*for some obscure reasons, dglGetEdge always returns NULL. Therefore this complicated enumeration of the edges... */
+    /* dglGetEdge is only supported with graphs version > 1. Therefore this complicated enumeration of the edges... */
     index = 0;
     G_message(_("Computing minimum spanning tree..."));
     G_percent_reset();
@@ -136,6 +138,7 @@ int NetA_spanning_tree(dglGraph_s * graph, struct ilist *tree_list)
 	    Vect_list_append(tree_list, dglEdgeGet_Id(graph, perm[i].edge));
 	}
     }
+    G_percent(index, index, 1);
     G_free(perm);
     uf_release(&uf);
     return edges;

+ 6 - 2
lib/vector/neta/utils.c

@@ -141,8 +141,12 @@ int NetA_get_node_costs(struct Map_info *In, int layer, char *column,
 	    if (!Vect_cat_get(Cats, layer, &cat))
 		continue;
 	    Vect_get_line_nodes(In, i, &node, NULL);
-	    if (db_CatValArray_get_value_double(&vals, cat, &value) == DB_OK)
-		node_costs[node] = value * In->dgraph.cost_multip;
+	    if (db_CatValArray_get_value_double(&vals, cat, &value) == DB_OK) {
+		if (value < 0)
+		    node_costs[node] = -1;
+		else
+		    node_costs[node] = value * In->dgraph.cost_multip;
+	    }
 	}
     }