-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from guissalustiano/feat/adds_util_topology_me…
…thods add utils methods to the topology
- Loading branch information
Showing
5 changed files
with
360 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,19 @@ | ||
use std::fs::File; | ||
|
||
use petgraph::algo::astar; | ||
use valley_free::{RelType, Topology}; | ||
use valley_free::Topology; | ||
|
||
fn main() { | ||
let file = File::open("20231201.as-rel.txt").unwrap(); | ||
let topo = Topology::from_caida(file).unwrap(); | ||
|
||
let university_of_twente_asn = 1133; | ||
let universidade_de_sao_paulo_asn = 28571; | ||
let ut_path = topo.paths_graph(university_of_twente_asn); | ||
let ut_path = topo.valley_free_of(university_of_twente_asn); | ||
|
||
// Use A* to find the shortest path between two nodes | ||
let (_len, path) = astar( | ||
&ut_path.graph, | ||
ut_path.index_of(university_of_twente_asn).unwrap(), | ||
|finish| finish == ut_path.index_of(universidade_de_sao_paulo_asn).unwrap(), | ||
|edge| match edge.weight() { | ||
// priorize pearing | ||
RelType::PearToPear => 0, | ||
RelType::ProviderToCustomer => 1, | ||
RelType::CustomerToProvider => 2, | ||
}, | ||
|_| 0, | ||
) | ||
.unwrap(); | ||
let path = path | ||
.iter() | ||
.map(|node| ut_path.asn_of(*node)) | ||
.collect::<Vec<_>>(); | ||
let path = ut_path | ||
.shortest_path_to(universidade_de_sao_paulo_asn) | ||
.unwrap(); | ||
|
||
println!("Path from UT to USP: {:?}", path); | ||
} |
Oops, something went wrong.