pub struct AttributedGraph<N: Node, E: EdgeWeight, Ix: IndexType = u32> { /* private fields */ }
Expand description
Graph with node and edge attributes
Implementations§
Source§impl<N: Node, E: EdgeWeight, Ix: IndexType> AttributedGraph<N, E, Ix>
impl<N: Node, E: EdgeWeight, Ix: IndexType> AttributedGraph<N, E, Ix>
Sourcepub fn from_graph(graph: Graph<N, E, Ix>) -> Self
pub fn from_graph(graph: Graph<N, E, Ix>) -> Self
Create an attributed graph from an existing graph
Sourcepub fn add_node_with_attributes(&mut self, node: N, attributes: Attributes)
pub fn add_node_with_attributes(&mut self, node: N, attributes: Attributes)
Add a node with initial attributes
Sourcepub fn add_edge(&mut self, source: N, target: N, weight: E) -> Result<()>
pub fn add_edge(&mut self, source: N, target: N, weight: E) -> Result<()>
Add an edge between two nodes with a given weight
Sourcepub fn add_edge_with_attributes(
&mut self,
source: N,
target: N,
weight: E,
attributes: Attributes,
) -> Result<()>
pub fn add_edge_with_attributes( &mut self, source: N, target: N, weight: E, attributes: Attributes, ) -> Result<()>
Add an edge with initial attributes
Sourcepub fn set_node_attribute<K: Into<String>>(
&mut self,
node: &N,
key: K,
value: AttributeValue,
)
pub fn set_node_attribute<K: Into<String>>( &mut self, node: &N, key: K, value: AttributeValue, )
Set a node attribute
Sourcepub fn get_node_attribute(&self, node: &N, key: &str) -> Option<&AttributeValue>
pub fn get_node_attribute(&self, node: &N, key: &str) -> Option<&AttributeValue>
Get a node attribute
Sourcepub fn get_node_attributes(&self, node: &N) -> Option<&Attributes>
pub fn get_node_attributes(&self, node: &N) -> Option<&Attributes>
Get all node attributes
Sourcepub fn get_node_attributes_mut(&mut self, node: &N) -> Option<&mut Attributes>
pub fn get_node_attributes_mut(&mut self, node: &N) -> Option<&mut Attributes>
Get mutable reference to node attributes
Sourcepub fn remove_node_attribute(
&mut self,
node: &N,
key: &str,
) -> Option<AttributeValue>
pub fn remove_node_attribute( &mut self, node: &N, key: &str, ) -> Option<AttributeValue>
Remove a node attribute
Sourcepub fn set_edge_attribute<K: Into<String>>(
&mut self,
source: &N,
target: &N,
key: K,
value: AttributeValue,
) -> Result<()>
pub fn set_edge_attribute<K: Into<String>>( &mut self, source: &N, target: &N, key: K, value: AttributeValue, ) -> Result<()>
Set an edge attribute
Sourcepub fn get_edge_attribute(
&self,
source: &N,
target: &N,
key: &str,
) -> Option<&AttributeValue>
pub fn get_edge_attribute( &self, source: &N, target: &N, key: &str, ) -> Option<&AttributeValue>
Get an edge attribute
Sourcepub fn get_edge_attributes(&self, source: &N, target: &N) -> Option<&Attributes>
pub fn get_edge_attributes(&self, source: &N, target: &N) -> Option<&Attributes>
Get all edge attributes
Sourcepub fn get_edge_attributes_mut(
&mut self,
source: &N,
target: &N,
) -> Option<&mut Attributes>
pub fn get_edge_attributes_mut( &mut self, source: &N, target: &N, ) -> Option<&mut Attributes>
Get mutable reference to edge attributes
Sourcepub fn remove_edge_attribute(
&mut self,
source: &N,
target: &N,
key: &str,
) -> Option<AttributeValue>
pub fn remove_edge_attribute( &mut self, source: &N, target: &N, key: &str, ) -> Option<AttributeValue>
Remove an edge attribute
Sourcepub fn set_graph_attribute<K: Into<String>>(
&mut self,
key: K,
value: AttributeValue,
)
pub fn set_graph_attribute<K: Into<String>>( &mut self, key: K, value: AttributeValue, )
Set a graph-level attribute
Sourcepub fn get_graph_attribute(&self, key: &str) -> Option<&AttributeValue>
pub fn get_graph_attribute(&self, key: &str) -> Option<&AttributeValue>
Get a graph-level attribute
Sourcepub fn get_graph_attributes(&self) -> &Attributes
pub fn get_graph_attributes(&self) -> &Attributes
Get all graph-level attributes
Sourcepub fn remove_graph_attribute(&mut self, key: &str) -> Option<AttributeValue>
pub fn remove_graph_attribute(&mut self, key: &str) -> Option<AttributeValue>
Remove a graph-level attribute
Sourcepub fn nodes_with_attribute(&self, key: &str) -> Vec<&N>
pub fn nodes_with_attribute(&self, key: &str) -> Vec<&N>
Get nodes with a specific attribute
Sourcepub fn nodes_with_attribute_value(
&self,
key: &str,
value: &AttributeValue,
) -> Vec<&N>
pub fn nodes_with_attribute_value( &self, key: &str, value: &AttributeValue, ) -> Vec<&N>
Get nodes where an attribute matches a specific value
Sourcepub fn edges_with_attribute(&self, key: &str) -> Vec<(&N, &N)>
pub fn edges_with_attribute(&self, key: &str) -> Vec<(&N, &N)>
Get edges with a specific attribute
Sourcepub fn edges_with_attribute_value(
&self,
key: &str,
value: &AttributeValue,
) -> Vec<(&N, &N)>
pub fn edges_with_attribute_value( &self, key: &str, value: &AttributeValue, ) -> Vec<(&N, &N)>
Get edges where an attribute matches a specific value
Sourcepub fn graph_mut(&mut self) -> &mut Graph<N, E, Ix>
pub fn graph_mut(&mut self) -> &mut Graph<N, E, Ix>
Get a mutable reference to the underlying graph
Sourcepub fn into_graph(self) -> Graph<N, E, Ix>
pub fn into_graph(self) -> Graph<N, E, Ix>
Convert back to a regular graph (losing attributes)
Sourcepub fn filter_nodes_by_attribute(
&self,
key: &str,
value: &AttributeValue,
) -> Self
pub fn filter_nodes_by_attribute( &self, key: &str, value: &AttributeValue, ) -> Self
Create a subgraph containing only nodes with specific attributes
Sourcepub fn attribute_summary(&self) -> AttributeSummary
pub fn attribute_summary(&self) -> AttributeSummary
Get summary statistics about attributes
Trait Implementations§
Auto Trait Implementations§
impl<N, E, Ix> Freeze for AttributedGraph<N, E, Ix>
impl<N, E, Ix> RefUnwindSafe for AttributedGraph<N, E, Ix>
impl<N, E, Ix> Send for AttributedGraph<N, E, Ix>where
Ix: Send,
impl<N, E, Ix> Sync for AttributedGraph<N, E, Ix>where
Ix: Sync,
impl<N, E, Ix> Unpin for AttributedGraph<N, E, Ix>
impl<N, E, Ix> UnwindSafe for AttributedGraph<N, E, Ix>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more