class Graphlb::DataStructures::Node

Overview

The node Class basically represnts the vertices in a graph it contains two properties

  1. name of the vertex
  2. edge shared with other vertex

edges property in Node reprensents the adjacency graph which is implemented using a hash with vertex name as it key and edge weight as its value

Defined in:

graphlb/data_structures/nodes.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String) #

creats a graph whith no vertices and edges(empty-graph)


[View source]

Instance Method Detail

def !=(other : Node) #

Checks the wheather the two node are not equal

@return : true if the two nodes are not equal, else false.


[View source]
def ==(other : Node) #

Checks the wheather the two node are equal

@return : true if the two nodes are equal, else false.


[View source]
def add_edge(to_node, weight) #

Adds a new edge from the self to the to_node

if to_node is not present in the greaph an exception is raised else an edge is created.

@param : to_node, the node where the edge ends,

@param : weight, the edge-weight,

@return : list of edges of the self node


[View source]
def edges : Hash(Graphlb::DataStructures::Node, Float64) #

A Hash to store the adjacency list of the vertex


[View source]
def name : String #

Name of the node, which is expexted to be unique for each vertex.


[View source]
def remove_edge(to_node) #

Removes an already existing edge from the graph

if to_node is not present in the greaph an exception is raised else an edge is created.

@param : to_node, the node where the edge ends,

@return : list of edges of the self node


[View source]