Skip to main content

VisualRDFGraph

Struct VisualRDFGraph 

Source
pub struct VisualRDFGraph { /* private fields */ }
Expand description

A visual representation of an RDF graph that can be converted to PlantUML diagrams.

This struct maintains mappings between RDF terms and visual nodes, tracks usage counts for different roles (subject, predicate, object), and manages the edges between nodes for visualization purposes.

Implementations§

Source§

impl VisualRDFGraph

Source

pub fn new(config: RDFVisualizationConfig) -> Self

Creates a new empty visual RDF graph with the given configuration.

§Arguments
  • config - Configuration settings for visualization
§Returns
  • A new VisualRDFGraph instance
Source

pub fn from_rdf<R: NeighsRDF>( rdf: &R, config: RDFVisualizationConfig, ) -> Result<Self, RDFError>

Creates a visual RDF graph from an RDF data source.

This method iterates through all triples in the RDF source and creates corresponding visual nodes and edges.

§Arguments
  • rdf - The RDF data source implementing NeighsRDF
  • config - Configuration for visualization
§Returns
  • Result<Self, RDFError> - The constructed graph or an error
Source

pub fn create_triple<R: NeighsRDF>( &mut self, rdf: &R, subject: R::Subject, predicate: R::IRI, object: R::Term, ) -> Result<VisualRDFNode, RDFError>

Creates a visual representation of an RDF triple in the graph.

This method converts RDF subject, predicate, and object into visual nodes, creates edges between them, and updates usage counts.

§Arguments
  • rdf - The RDF data source
  • subject - The subject of the triple
  • predicate - The predicate of the triple
  • object - The object of the triple
§Returns
  • Result<VisualRDFNode, RDFError> - The created triple node or an error
Source

pub fn create_triple_term<R: NeighsRDF>( &mut self, rdf: &R, subject: R::Subject, predicate: R::IRI, object: R::Term, ) -> Result<VisualRDFNode, RDFError>

Creates a visual representation of an RDF triple as a term (for RDF-star).

Similar to create_triple but handles triple terms differently, without creating edges in the visual graph.

§Arguments
  • rdf - The RDF data source
  • subject - The subject of the triple
  • predicate - The predicate of the triple
  • object - The object of the triple
§Returns
  • Result<VisualRDFNode, RDFError> - The created triple term node or an error
Source

pub fn increment_usage_count_as_subject(&mut self, node: &VisualRDFNode)

Increments the usage count for a node when used as a subject.

§Arguments
  • node - The node to increment the count for
Source

pub fn increment_usage_count_as_subject_in_triple( &mut self, node: &VisualRDFNode, )

Increments the usage count for a node when used as a subject in a triple term.

§Arguments
  • node - The node to increment the count for
Source

pub fn increment_usage_count_as_predicate(&mut self, node: &VisualRDFNode)

Increments the usage count for a node when used as a predicate.

§Arguments
  • node - The node to increment the count for
Source

pub fn increment_usage_count_as_predicate_in_triple( &mut self, node: &VisualRDFNode, )

Increments the usage count for a node when used as a predicate in a triple term.

§Arguments
  • node - The node to increment the count for
Source

pub fn increment_usage_count_as_object(&mut self, node: &VisualRDFNode)

Increments the usage count for a node when used as an object.

§Arguments
  • node - The node to increment the count for
Source

pub fn increment_usage_count_as_object_in_triple( &mut self, node: &VisualRDFNode, )

Increments the usage count for a node when used as an object in a triple term.

§Arguments
  • node - The node to increment the count for
Source

pub fn get_or_create_node(&mut self, node: VisualRDFNode) -> NodeId

Gets the ID of a node, creating it if it doesn’t exist.

§Arguments
  • node - The node to get or create an ID for
§Returns
  • NodeId - The unique ID for the node
Source

pub fn get_node_id( &self, node: &VisualRDFNode, ) -> Result<NodeId, RdfVisualizerError>

Gets the ID of an existing node.

§Arguments
  • node - The node to get the ID for
§Returns
  • Result<NodeId, RdfVisualizerError> - The node ID or an error if not found
Source

pub fn as_plantuml<W: Write>( &self, writer: &mut W, _mode: &UmlGenerationMode, ) -> Result<(), RdfVisualizerError>

Converts the visual graph to PlantUML format and writes it to the given writer.

§Arguments
  • writer - The writer to output the PlantUML code to
  • _mode - The generation mode (currently unused)
§Returns
  • Result<(), RdfVisualizerError> - Ok if successful, Err with details on failure
Source

pub fn show_node(&self, node: &VisualRDFNode) -> bool

Determines whether a node should be shown in the visualization.

Some nodes (like predicates) are only shown if they appear in triple terms.

§Arguments
  • node - The node to check
§Returns
  • bool - True if the node should be visualized

Trait Implementations§

Source§

impl Display for VisualRDFGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the visual graph for debugging and logging purposes.

Shows the number of nodes and edges, plus details about each node and edge in the graph.

Source§

impl UmlConverter for VisualRDFGraph

Source§

fn as_plantuml<W: Write>( &self, writer: &mut W, mode: &UmlGenerationMode, ) -> Result<(), UmlConverterError>

Converts the visual graph to PlantUML format.

This implementation delegates to the struct’s own as_plantuml method.

Source§

fn as_image<W: Write, P: AsRef<Path>>( &self, writer: &mut W, image_format: ImageFormat, mode: &UmlGenerationMode, plantuml_path: P, ) -> Result<(), UmlConverterError>

Converts the implementing type to an image format using PlantUML. Read more
Source§

fn save_uml_to_tempfile( &self, tempfile_path: &Path, tempfile_name: &str, mode: &UmlGenerationMode, ) -> Result<(), UmlConverterError>

Saves the UML representation to a temporary file. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more