Home | History | Annotate | Download | only in src

Lines Matching refs:graph

2872 *                                 Graph  implementation                                  *
2875 /* Create a new graph: */
2880 CvGraph *graph = 0;
2900 graph = (CvGraph*)vertices;
2901 graph->edges = edges;
2905 return graph;
2909 /* Remove all vertices and edges from a graph: */
2911 cvClearGraph( CvGraph * graph )
2917 if( !graph )
2920 cvClearSet( graph->edges );
2921 cvClearSet( (CvSet*)graph );
2927 /* Add a vertex to a graph: */
2929 cvGraphAddVtx( CvGraph* graph, const CvGraphVtx* _vertex, CvGraphVtx** _inserted_vertex )
2938 if( !graph )
2941 vertex = (CvGraphVtx*)cvSetNew((CvSet*)graph);
2946 (size_t)(graph->elem_size - sizeof(CvGraphVtx))/sizeof(int) );
2960 /* Remove a vertex from the graph together with its incident edges: */
2962 cvGraphRemoveVtxByPtr( CvGraph* graph, CvGraphVtx* vtx )
2970 if( !graph || !vtx )
2974 CV_ERROR( CV_StsBadArg, "The vertex does not belong to the graph" );
2976 count = graph->edges->active_count;
2982 cvGraphRemoveEdgeByPtr( graph, edge->vtx[0], edge->vtx[1] );
2984 count -= graph->edges->active_count;
2985 cvSetRemoveByPtr( (CvSet*)graph, vtx );
2993 /* Remove a vertex from the graph together with its incident edges: */
2995 cvGraphRemoveVtx( CvGraph* graph, int index )
3004 if( !graph )
3007 vtx = cvGetGraphVtx( graph, index );
3011 count = graph->edges->active_count;
3019 cvGraphRemoveEdgeByPtr( graph, edge->vtx[0], edge->vtx[1] );
3021 count -= graph->edges->active_count;
3022 cvSetRemoveByPtr( (CvSet*)graph, vtx );
3030 /* Find a graph edge given pointers to the ending vertices: */
3032 cvFindGraphEdgeByPtr( const CvGraph* graph,
3043 if( !graph || !start_vtx || !end_vtx )
3049 if( !CV_IS_GRAPH_ORIENTED( graph ) &&
3071 /* Find an edge in the graph given indices of the ending vertices: */
3073 cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx )
3083 if( !graph )
3084 CV_ERROR( CV_StsNullPtr, "graph pointer is NULL" );
3086 start_vtx = cvGetGraphVtx( graph, start_idx );
3087 end_vtx = cvGetGraphVtx( graph, end_idx );
3089 edge = cvFindGraphEdgeByPtr( graph, start_vtx, end_vtx );
3102 cvGraphAddEdgeByPtr( CvGraph* graph,
3116 if( !graph )
3117 CV_ERROR( CV_StsNullPtr, "graph pointer is NULL" );
3119 if( !CV_IS_GRAPH_ORIENTED( graph ) &&
3126 CV_CALL( edge = cvFindGraphEdgeByPtr( graph, start_vtx, end_vtx ));
3137 CV_CALL( edge = (CvGraphEdge*)cvSetNew( (CvSet*)(graph->edges) ));
3146 delta = (graph->edges->elem_size - sizeof(*edge))/sizeof(int);
3175 cvGraphAddEdge( CvGraph* graph,
3188 if( !graph )
3191 start_vtx = cvGetGraphVtx( graph, start_idx );
3192 end_vtx = cvGetGraphVtx( graph, end_idx );
3194 result = cvGraphAddEdgeByPtr( graph, start_vtx, end_vtx, _edge, _inserted_edge );
3202 /* Remove the graph edge connecting two given vertices: */
3204 cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, CvGraphVtx* end_vtx )
3213 if( !graph || !start_vtx || !end_vtx )
3219 if( !CV_IS_GRAPH_ORIENTED( graph ) &&
3261 cvSetRemoveByPtr( graph->edges, edge );
3267 /* Remove the graph edge connecting two given vertices: */
3269 cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx )
3278 if( !graph )
3281 start_vtx = cvGetGraphVtx( graph, start_idx );
3282 end_vtx = cvGetGraphVtx( graph, end_idx );
3284 cvGraphRemoveEdgeByPtr( graph, start_vtx, end_vtx );
3292 cvGraphVtxDegreeByPtr( const CvGraph* graph, const CvGraphVtx* vertex )
3301 if( !graph || !vertex )
3318 cvGraphVtxDegree( const CvGraph* graph, int vtx_idx )
3328 if( !graph )
3331 vertex = cvGetGraphVtx( graph, vtx_idx );
3448 cvCreateGraphScanner( CvGraph* graph, CvGraphVtx* vtx, int mask )
3457 if( !graph )
3458 CV_ERROR( CV_StsNullPtr, "Null graph pointer" );
3460 CV_ASSERT( graph->storage != 0 );
3465 scanner->graph = graph;
3470 CV_CALL( child_storage = cvCreateChildMemStorage( graph->storage ));
3475 CV_CALL( icvSeqElemsClearFlags( (CvSeq*)graph,
3480 CV_CALL( icvSeqElemsClearFlags( (CvSeq*)(graph->edges),
3504 CV_ERROR( CV_StsNullPtr, "Null double pointer to graph scanner" );
3532 CV_ERROR( CV_StsNullPtr, "Null graph scanner" );
3565 if( !CV_IS_GRAPH_ORIENTED( scanner->graph ) || dst != edge->vtx[0] )
3650 vtx = (CvGraphVtx*)icvSeqFindNextElem( (CvSeq*)(scanner->graph),
3679 cvCloneGraph( const CvGraph* graph, CvMemStorage* storage )
3693 if( !CV_IS_GRAPH(graph))
3694 CV_ERROR( CV_StsBadArg, "Invalid graph pointer" );
3697 storage = graph->storage;
3702 vtx_size = graph->elem_size;
3703 edge_size = graph->edges->elem_size;
3705 CV_CALL( flag_buffer = (int*)cvAlloc( graph->total*sizeof(flag_buffer[0])));
3706 CV_CALL( ptr_buffer = (CvGraphVtx**)cvAlloc( graph->total*sizeof(ptr_buffer[0])));
3707 CV_CALL( result = cvCreateGraph( graphgraph->header_size,
3709 memcpy( result + sizeof(CvGraph), graph + sizeof(CvGraph),
3710 graph->header_size - sizeof(CvGraph));
3713 cvStartReadSeq( (CvSeq*)graph, &reader );
3714 for( i = 0, k = 0; i < graph->total; i++ )
3729 cvStartReadSeq( (CvSeq*)graph->edges, &reader );
3730 for( i = 0; i < graph->edges->total; i++ )
3745 cvStartReadSeq( (CvSeq*)graph, &reader );
3746 for( i = 0, k = 0; i < graph->edges->total; i++ )