Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
subgraph.c
Package: leda.tar.gz [view]
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 1k
Category:
Mathimatics-Numerical algorithms
Development Platform:
MultiPlatform
- #include <LEDA/graph.h>
- #include <LEDA/graph_alg.h>
- GRAPH<int,int> shortest_path_tree(GRAPH<int,int>& G, edge_array<int>& cost)
- {
- // returns a shortest-paths tree as a subgraph of G
- node_array<int> dist(G);
- node_array<edge> pred(G);
- node s = G.first_node();
- DIJKSTRA(G,s,cost,dist,pred);
- list<edge> el;
- node v;
- forall_nodes(v,G) if (pred[v]!=0) el.append(pred[v]);
- return GRAPH<int,int>(G,G.all_nodes(),el); // subgraph constructor
- }
- main()
- { GRAPH<int,int> G;
- test_graph(G);
- edge_array<int> cost(G);
- int a = read_int("a = ");
- int b = read_int("b = ");
- random_source ran(a,b);
- edge e;
- forall_edges(e,G) cost[e] = G[e] = ran();
- GRAPH<int,int> S = shortest_path_tree(G,cost);
- G.print("graph G");
- newline;
- S.print("subgraph S");
- newline;
- edge_array<int> cost1(S);
- forall_edges(e,S) cost1[e] = S[e];
- GRAPH<int,int> S1 = shortest_path_tree(S,cost1);
- S1.print("subgraph S1");
- newline;
- return 0;
- }