Graphs Flashcards
Graph
A graph consists of end points (vertices/nodes) that are joined by lines(edges/arcs)
degree of a vertex
the number of edges(lines) going away from a vertex
Isolated Vertex
has no neighboring vertices connected to it
Cycle
edges creating returns to connected vertices
examples of use of graphs
-modelling gas pipelines
-managing air transport systems
-representing computer networks
types of graph
-labeled/unlabeled
-weighted/unweighted
-directional/unidirectional
Adjacent Matrix
representing vertex connections to other vertices (grid)
adjacency list
collection of lists which represents the neighbors of each vertex(node) in a graph
adjacency (list vs matrix)
+more space efficient (not storing 0s/ repeats for undirected graphs)
-longer programming time if you want to make object based list for weighted graphs
Tree Graph
graph that is…undirected…has no cycles
Binary tree
undirected graph with no cycles where…each vertex has two children at most and there is a clear root node
Creating binary trees from list of strings
- Put them in via the order they are given (i.e. first is root)
- compare the weight for subsequent letters (heavier nodes go right) (lighter nodes go left) and go below a node that takes a side
- move onto second letter if they have the same first letter