Graphs and Programgraphs Flashcards
What is a directed graph?
A directed graph, also known as a digraph, is a set of nodes or vertices connected by edges, where the edges have a direction and connect one node to another.
What does a directed graph consist of?
A directed graph consists of a set of nodes or vertices (V) and a set of edges (E).
What is an edge in a directed graph?
An edge in a directed graph is a pair of nodes that shows the direction of the edge. The pair is written as (n, m), where n is the start node and m is the end node.
What is the difference between a directed graph and an undirected graph?
In a directed graph, edges have a direction, whereas in an undirected graph, edges have no direction.
What is the indegree of a node in a directed graph?
The indegree of a node in a directed graph is the number of edges that have the node as their end node.
What is the outdegree of a node in a directed graph?
The outdegree of a node in a directed graph is the number of edges that have the node as their start node.
Can a node in a directed graph have both indegree and outdegree?
Yes, a node in a directed graph can have both indegree and outdegree, or it can have only one of them depending on the graph structure.
What is a source node in a directed graph?
A source node is a node in a directed graph with an indegree of 0, meaning there are no edges pointing into that node.
What is a sink node in a directed graph?
A sink node is a node in a directed graph with an outdegree of 0, meaning there are no edges coming out of that node.
What is a transfer node in a directed graph?
A transfer node is a node in a directed graph with both an indegree and an outdegree that are greater than 0, meaning there are edges coming into and out of that node.
What is a directed path in a graph?
A directed path is a sequence of edges in a directed graph where each edge connects the end node of the previous edge to the start node of the next edge.
What is the empty sequence in a directed path?
The empty sequence, denoted by <>, is a valid directed path in a graph that consists of no edges and no nodes.
What is a cycle in a directed graph?
A cycle in a directed graph is a directed path that begins and ends at the same node, with at least one non-empty sequence of edges between the start and end nodes.
Is the empty sequence a cycle in a directed graph?
No, the empty sequence is not a cycle in a directed graph because it does not connect any nodes or edges.
What is control flow?
Control flow, also known as flow of control, refers to the order in which statements within a program are executed.