Trait caminos_lib::topology::Topology[][src]

pub trait Topology: Quantifiable + Debug {
Show 26 methods fn num_routers(&self) -> usize;
fn num_servers(&self) -> usize;
fn neighbour(&self, router_index: usize, port: usize) -> (Location, usize);
fn server_neighbour(&self, server_index: usize) -> (Location, usize);
fn diameter(&self) -> usize;
fn distance(&self, origin: usize, destination: usize) -> usize;
fn amount_shortest_paths(&self, origin: usize, destination: usize) -> usize;
fn average_amount_shortest_paths(&self) -> f32;
fn maximum_degree(&self) -> usize;
fn minimum_degree(&self) -> usize;
fn degree(&self, router_index: usize) -> usize;
fn ports(&self, router_index: usize) -> usize;
fn cartesian_data(&self) -> Option<&CartesianData>;
fn coordinated_routing_record(
        &self,
        coordinates_a: &Vec<usize>,
        coordinates_b: &Vec<usize>,
        rng: Option<&RefCell<StdRng>>
    ) -> Vec<i32>;
fn is_direction_change(
        &self,
        router_index: usize,
        input_port: usize,
        output_port: usize
    ) -> bool;
fn up_down_distance(
        &self,
        origin: usize,
        destination: usize
    ) -> Option<(usize, usize)>; fn neighbour_router_iter<'a>(
        &'a self,
        router_index: usize
    ) -> Box<dyn Iterator<Item = NeighbourRouterIteratorItem> + 'a> { ... }
fn bfs(&self, origin: usize, class_weight: Option<&[usize]>) -> Vec<usize> { ... }
fn compute_distance_matrix(
        &self,
        class_weight: Option<&[usize]>
    ) -> Matrix<usize> { ... }
fn floyd(&self) -> Matrix<usize> { ... }
fn compute_amount_shortest_paths(&self) -> (Matrix<usize>, Matrix<usize>) { ... }
fn components(&self, allowed_classes: &[bool]) -> Vec<Vec<usize>> { ... }
fn compute_near_far_matrices(&self) -> (Matrix<usize>, Matrix<usize>) { ... }
fn eccentricity(&self, router_index: usize) -> usize { ... }
fn check_adjacency_consistency(&self, amount_link_classes: Option<usize>) { ... }
fn write_adjacencies_to_file(
        &self,
        file: &mut File,
        _format: usize
    ) -> Result<(), Error> { ... }
}
Expand description

A topology describes how routers and servers are connected. The router index has ports(index) neighbours. The first degree(index) must be other routers.

Required methods

Neighbours of a router: Location+link class index Routers should be before servers

The neighbour of a server: Location+link class index

the greatest distance from server to server

Distance from a router to another.

Number of shortest paths from a router to another.

Average number of shortest paths from a router to another.

Number of ports used to other routers. This does not include non-connected ports. This should not be used as a range of valid ports. A non-connected port can be before some other valid port to a router. Use neighbour_router_iter()' or 0..ports()’ to iterate over valid ranges.

Specific for some toologies, but must be checkable for anyone

Specific for some toologies, but must be checkable for anyone

Specific for some toologies, but must be checkable for anyone Indicates if going from input_port to output_port implies a direction change. Used for the bubble routing.

For topologies containing the so called up/down paths. Other topologies should return always None. If the return is Some((u,d)) it means there is an initial up sub-path of length u followed by a down sub-path of length d starting at origin and ending at destination. A return value of None means there is no up/down path from origin to destination. Some general guidelines, although it is not clear if they must hold always:

  • If there is a down path of length d then return Some((0,d))
  • If there is a up path of length u then return Some((u,0))
  • If up_down_distance(s,t)=(u,d) with u>0 then some neighour m of s should have up_down_distance(m,t)=(u-1,d)
  • Return always a path of least u+d.
  • Minimize u before d?
  • If up_down_distance(s,t)=(u,d) then up_down_distance(t,s)=(d,u)?
  • In multistage networks u-d is the difference on levels and allows for some algebra. Note that in general u+d is not an actual distance, since the triangular inequality does not hold.

Provided methods

Iterate over the neighour routers, skipping non-connected ports and ports towards servers. You may want to reimplement this when implementing the trait for your type.

Breadth First Search to compute distances from a router to all others. It may use weights, but it there are multiple paths with different distances it may give a non-minimal distance, since it is not Dijkstra.

Return a pair of matrices (D,A) with D[i,j] being the distance from i to j and A[i,j] being the number of paths of length D[i,j] from i to j.

Find the coponents of the subtopology induced via the allowed links. Returns vector ret with ret[k] containing the vertices in the k-th component.

returns a cople matrices (N,F) with N[u,v] = number of neighbours w of v with D(u,v)>D(u,w). F[u,v] = number of neighbours w of v with D(u,v)<D(u,w). A router v with F[u,v]=0 is called a boundary vertex of u.

Computes the eccentricy of a router. That is, the greatest possible length of a shortest path from that router to any other.

Check pairs (port,vc) with

  • non-matching endpoint (this is, going backwards a wire you should return to the same router/server)
  • breaking the servers-last rule
  • optionally check that the link class is within bounds.

Dump the adjacencies into a file. You may use NeighboursLists::file_adj to load them.

Implementors