Remove the graph edge connecting two given vertices: */
| 2830 | |
| 2831 | /* Remove the graph edge connecting two given vertices: */ |
| 2832 | CV_IMPL void |
| 2833 | cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, CvGraphVtx* end_vtx ) |
| 2834 | { |
| 2835 | int ofs, prev_ofs; |
| 2836 | CvGraphEdge *edge, *next_edge, *prev_edge; |
| 2837 | |
| 2838 | if( !graph || !start_vtx || !end_vtx ) |
| 2839 | CV_Error( CV_StsNullPtr, "" ); |
| 2840 | |
| 2841 | if( start_vtx == end_vtx ) |
| 2842 | return; |
| 2843 | |
| 2844 | if( !CV_IS_GRAPH_ORIENTED( graph ) && |
| 2845 | (start_vtx->flags & CV_SET_ELEM_IDX_MASK) > (end_vtx->flags & CV_SET_ELEM_IDX_MASK) ) |
| 2846 | { |
| 2847 | CvGraphVtx* t; |
| 2848 | CV_SWAP( start_vtx, end_vtx, t ); |
| 2849 | } |
| 2850 | |
| 2851 | for( ofs = prev_ofs = 0, prev_edge = 0, edge = start_vtx->first; edge != 0; |
| 2852 | prev_ofs = ofs, prev_edge = edge, edge = edge->next[ofs] ) |
| 2853 | { |
| 2854 | ofs = start_vtx == edge->vtx[1]; |
| 2855 | assert( ofs == 1 || start_vtx == edge->vtx[0] ); |
| 2856 | if( edge->vtx[1] == end_vtx ) |
| 2857 | break; |
| 2858 | } |
| 2859 | |
| 2860 | if( !edge ) |
| 2861 | return; |
| 2862 | |
| 2863 | next_edge = edge->next[ofs]; |
| 2864 | if( prev_edge ) |
| 2865 | prev_edge->next[prev_ofs] = next_edge; |
| 2866 | else |
| 2867 | start_vtx->first = next_edge; |
| 2868 | |
| 2869 | for( ofs = prev_ofs = 0, prev_edge = 0, edge = end_vtx->first; edge != 0; |
| 2870 | prev_ofs = ofs, prev_edge = edge, edge = edge->next[ofs] ) |
| 2871 | { |
| 2872 | ofs = end_vtx == edge->vtx[1]; |
| 2873 | assert( ofs == 1 || end_vtx == edge->vtx[0] ); |
| 2874 | if( edge->vtx[0] == start_vtx ) |
| 2875 | break; |
| 2876 | } |
| 2877 | |
| 2878 | assert( edge != 0 ); |
| 2879 | |
| 2880 | next_edge = edge->next[ofs]; |
| 2881 | if( prev_edge ) |
| 2882 | prev_edge->next[prev_ofs] = next_edge; |
| 2883 | else |
| 2884 | end_vtx->first = next_edge; |
| 2885 | |
| 2886 | cvSetRemoveByPtr( graph->edges, edge ); |
| 2887 | } |
| 2888 | |
| 2889 |
no test coverage detected