分支限界---单源最短路径
#分支限界 -- - 单源最短路径 # include <iostream> # include <bits/stdc++.h> using namespace std ; # define inf 0x3f3f3f int c [ 100 ] [ 100 ] ; int dist [ 100 ] ; int prev [ 100 ] ; int n ; struct Vex { int i ; int length ; bool operator < ( const Vex & v ) const { return length > v . length ; } Vex ( ) { } ; Vex ( int v , int l ) { i = v ; length = l ; } } ; void shortest ( int v0 ) { priority_queue < Vex > Q ; Vex E ; E . i = v0 ; E . length = 0 ; Q . push ( E ) ; dist [ v0 ] = 0 ; while ( ! Q . empty ( ) ) { E = Q . top ( ) ; for ( int j = 1 ; j <= n ; j ++ ) { if ( ( c [ E . i ] [ j ] < inf ) && ( c