It includes:
Introduction to Graphs
Applications
Graph representation
Graph terminology
Graph operations
Adding vertex and edge in Adjacency matrix representation using C++ program
Adjacency List implementation in C++
Homework Problems
References
The solution to the single-source shortest-path tree problem in graph theory. This slide was prepared for Design and Analysis of Algorithm Lab for B.Tech CSE 2nd Year 4th Semester.
Trees. Defining, Creating and Traversing Trees. Traversing the File System
Binary Search Trees. Balanced Trees
Graphs and Graphs Traversal Algorithms
Exercises: Working with Trees and Graphs
It includes:
Introduction to Graphs
Applications
Graph representation
Graph terminology
Graph operations
Adding vertex and edge in Adjacency matrix representation using C++ program
Adjacency List implementation in C++
Homework Problems
References
The solution to the single-source shortest-path tree problem in graph theory. This slide was prepared for Design and Analysis of Algorithm Lab for B.Tech CSE 2nd Year 4th Semester.
Trees. Defining, Creating and Traversing Trees. Traversing the File System
Binary Search Trees. Balanced Trees
Graphs and Graphs Traversal Algorithms
Exercises: Working with Trees and Graphs
Euclid's Algorithm for Greatest Common Divisor - Time Complexity AnalysisAmrinder Arora
Euclid's algorithm for finding greatest common divisor is an elegant algorithm that can be written iteratively as well as recursively. The time complexity of this algorithm is O(log^2 n) where n is the larger of the two inputs.
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...Amrinder Arora
Chan's Algorithm for Convex Hull Problem. Output Sensitive Algorithm. Takes O(n log h) time. Presentation for the final project in CS 6212/Spring/Arora.
Dynamic Programming design technique is one of the fundamental algorithm design techniques, and possibly one of the ones that are hardest to master for those who did not study it formally. In these slides (which are continuation of part 1 slides), we cover two problems: maximum value contiguous subarray, and maximum increasing subsequence.
Who am I and why do I feel that the world is not infinitely perfect? Which technologies should I use to rectify this situation? Enter the graph and the graph traversal.
NP completeness. Classes P and NP are two frequently studied classes of problems in computer science. Class P is the set of all problems that can be solved by a deterministic Turing machine in polynomial time.
Dynamic Programming is one of the most interesting design techniques. The concise idea is to avoid recomputations. Matrix Chain Multiplication and All Pairs Shortest Paths are two interesting applications of this design technique
How multiple experts can be leveraged in a machine learning application without knowing apriori who are "good" experts and who are "bad" experts. See how we can quantify the bounds on the overall results.
Trie (aka radix tree or prefix tree), is an ordered tree data structure where the keys are usually strings. Tries have tremendous applications from all sorts of things like dictionary to
This is the second lecture in the CS 6212 class. Covers asymptotic notation and data structures. Also outlines the coming lectures wherein we will study the various algorithm design techniques.
Array is a container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. Following are the important terms to understand the concept of array.
Set Operations - Union Find and Bloom FiltersAmrinder Arora
Set Operations - make set, union, find and contains are standard operations that appear in many scenarios. Union Find is a marvelous data structure to solve problems involving union and find operations.
Different use arises when we merely want to answer queries on whether a set contains an element x without keeping the entire set in the memory. Bloom Filters play an interesting role there.
Splay Trees and Self Organizing Data StructuresAmrinder Arora
Self Organizing Data Structures, such as Splay Trees, continue to adjust themselves based on the operation sequence. They are much easier to implement compared to AVL or RB Trees. Amortized time is O(log n), although worst case time may be O(n).
A Graph is a non-linear data structure, which consists of vertices(or nodes) connected by edges(or arcs) where edges may be directed or undirected.
Graphs are a powerful and versatile data structure that easily allow you to represent real life relationships between different types of data (nodes).
Graph is a non-linear data structure used to represent the connection between entities.
consists of vertices and edges.
Directed
In a directed graph, edges have a specific direction. They represent relationship where one node points to another i.e., edges go from one vertex to another.
undirected:
Undirected graphs have bidirectional edges. They represent symmetric relationships, like friendships on a social networks
by uj and za
ON FINDING MINIMUM AND MAXIMUM PATH LENGTH IN GRID-BASED WIRELESS NETWORKSijwmn
In this paper, we obtain the minimum and maximum hop counts between any pair of cells in the 3D gridbased wireless networks. We start by determining the minimum path length between any two points in a 2D grid coordinate system. We establish that the minimum path length is the maximum difference between the
corresponding coordinates of the two points. We then extend the result to derive the minimum and maximum hop counts for the 3D grid-based wireless networks. We establish that the maximum path length is the sum of the differences between the corresponding coordinates of the two cells. Whilst the minimum path length depends on the positions of the two cells; it does not exceed the maximum difference between the corresponding coordinates of the two cells.
ON ALGORITHMIC PROBLEMS CONCERNING GRAPHS OF HIGHER DEGREE OF SYMMETRYFransiskeran
Since the ancient determination of the five platonic solids the study of symmetry and regularity has always
been one of the most fascinating aspects of mathematics. One intriguing phenomenon of studies in graph
theory is the fact that quite often arithmetic regularity properties of a graph imply the existence of many
symmetries, i.e. large automorphism group G. In some important special situation higher degree of
regularity means that G is an automorphism group of finite geometry. For example, a glance through the
list of distance regular graphs of diameter d < 3 reveals the fact that most of them are connected with
classical Lie geometry. Theory of distance regular graphs is an important part of algebraic combinatorics
and its applications such as coding theory, communication networks, and block design. An important tool
for investigation of such graphs is their spectra, which is the set of eigenvalues of adjacency matrix of a
graph. Let G be a finite simple group of Lie type and X be the set homogeneous elements of the associated
geometry.
Similar to Graphs, Trees, Paths and Their Representations (20)
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet MahanaAmrinder Arora
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana. Presentation for CS 6212 final project in GWU during Fall 2015 (Prof. Arora's class)
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...Amrinder Arora
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Alshami and Dong Wang. Final Presentation for P4, in CS 6212, Fall 2015 taught by Prof. Arora.
Divide and Conquer Algorithms - D&C forms a distinct algorithm design technique in computer science, wherein a problem is solved by repeatedly invoking the algorithm on smaller occurrences of the same problem. Binary search, merge sort, Euclid's algorithm can all be formulated as examples of divide and conquer algorithms. Strassen's algorithm and Nearest Neighbor algorithm are two other examples.
Introduction to Algorithms and Asymptotic NotationAmrinder Arora
Asymptotic Notation is a notation used to represent and compare the efficiency of algorithms. It is a concise notation that deliberately omits details, such as constant time improvements, etc. Asymptotic notation consists of 5 commonly used symbols: big oh, small oh, big omega, small omega, and theta.
Heaps and Priority Queues allow data to be accessed in an order. Binary heaps are great, but don't support merging (unions). Binomial heaps solve that problem. Dijkstra and Prim's algorithm can benefit greatly from using a decrease key operation that runs in O(1) time. Fibonacci heaps provide that, while keeping the extract min operation to O(log n) time. Amortized analysis can be used for both.
R-Trees are an excellent data structure for managing geo-spatial data. Commonly used by mapping applications and any other applications that use the location to customize content. Minimum Bounding Rectangle (MBR) is a commonly used concept in R-trees, which are a modified form of B-trees.
BTrees - Great alternative to Red Black, AVL and other BSTsAmrinder Arora
BTrees - designed by Rudolf Bayer and Ed McCreight - fundamental data structure in computer science. Great alternative to BSTs. Very appropriate for disk based access.
This presentation defines online algorithms, and discusses how we can analyze them using competitive analysis. Using ski rental and ice cream machine as example problems, it covers the applications of online algorithms in load balancing and other verticals.
I teach Computer Science, usually algorithms at George Washington University. But once during the semester, I cover something about the learning process itself.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Thinking of getting a dog? Be aware that breeds like Pit Bulls, Rottweilers, and German Shepherds can be loyal and dangerous. Proper training and socialization are crucial to preventing aggressive behaviors. Ensure safety by understanding their needs and always supervising interactions. Stay safe, and enjoy your furry friends!
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
Delivering Micro-Credentials in Technical and Vocational Education and TrainingAG2 Design
Explore how micro-credentials are transforming Technical and Vocational Education and Training (TVET) with this comprehensive slide deck. Discover what micro-credentials are, their importance in TVET, the advantages they offer, and the insights from industry experts. Additionally, learn about the top software applications available for creating and managing micro-credentials. This presentation also includes valuable resources and a discussion on the future of these specialised certifications.
For more detailed information on delivering micro-credentials in TVET, visit this https://tvettrainer.com/delivering-micro-credentials-in-tvet/
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
How to Add Chatter in the odoo 17 ERP ModuleCeline George
In Odoo, the chatter is like a chat tool that helps you work together on records. You can leave notes and track things, making it easier to talk with your team and partners. Inside chatter, all communication history, activity, and changes will be displayed.
2. Instructor
Prof. Amrinder Arora
amrinder@gwu.edu
Please copy TA on emails
Please feel free to call as well
TA
Iswarya Parupudi
iswarya2291@gwmail.gwu.edu
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 2
LOGISTICS
3. L4 - BTrees CS 6213 - Advanced Data Structures - Arora 3
CS 6213
Basics
Record /
Struct
Arrays / Linked
Lists / Stacks
/ Queues
Graphs / Trees
/ BSTs
Advanced
Trie, B-Tree
Splay Trees
R-Trees
Heaps and PQs
Union Find
4. Graphs – Basics
Degrees, Number of Edges, Min/Max Degree
Kinds of Graphs
How to Represent in Data Structures
Trees, Paths, Cycles
Journeys
Topological Sorting, DAGs
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 4
AGENDA
5. A graph G=(V,E) consists of a finite set V, which is the
set of vertices, and set E, which is the set of edges.
Each edge in E connects two vertices v1 and v2,
which are in V.
Can be directed or undirected
Not to be confused with a bar graph!!!!
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 5
GRAPH
6. A core data structure that shows up in many
circumstances:
Transportation and Logistics (paths, etc.)
Circuit Design
Social Networking – Model connections between people
Sociology – Model influence
Zoology and Wildlife
Project Task Management
Job Scheduling and Resource Assignment (matching)
Time table scheduling
Task parallelization (graph coloring)
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 6
GRAPH – APPLICATIONS
7. (Undirected) Degree of a node
(Directed) Indegree / Outdegree
Min degree in a graph:
Max degree in a graph:
Basic observations
(Undirected) Sum of degrees = 2 x number of edges
(Directed) Sum of indegree = Sum of outdegree = number of
edges
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 7
DEGREE
8. If (x,y) is an edge, then x is said to be adjacent to y, and y is adjacent
from x.
In the case of undirected graphs, if (x,y) is an edge, we just say that x
and y are adjacent (or x is adjacent to y, or y is adjacent to x). Also, we
say that x is the neighbor of y.
The indegree of a node x is the number of nodes adjacent to x
The outdegree of a node x is the number of nodes adjacent from x
The degree of a node x in an undirected graph is the number of
neighbors of x
A path from a node x to a node y in a graph is a sequence of node x,
x1,x2,...,xn,y, such that x is adjacent to x1, x1 is adjacent to x2, ..., and xn
is adjacent to y.
The length of a path is the number of its edges.
A cycle is a path that begins and ends at the same node
The distance from node x to node y is the length of the shortest path
from x to y.
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 8
GRAPH DEFINITIONS
9. Using a matrix A[1..n,1..n] where A[i,j] = 1 if (i,j) is an
edge, and is 0 otherwise. This representation is called
the adjacency matrix representation. If the graph is
undirected, then the adjacency matrix is symmetric about
the main diagonal.
Using an array Adj[1..n] of pointers, which Adj[i] is a
linked list of nodes which are adjacent to i.
The matrix representation requires more memory, since it
has a matrix cell for each possible edge, whether that
edge exists or not. In adjacency list representation, the
space used is directly proportional to the number of
edges.
If the graph is sparse (very few edges), then adjacency
list may be a more efficient choice.
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 9
GRAPH REPRESENTATIONS
10. A very practical choice is to use graphing libraries,
such as:
JGraphT (Java)
Boost (C++)
GraphStream (Java)
JUNG (Java)
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 10
GRAPH REPRESENTATION (CONT.)
11. Graphs can be characterized in many ways. Two
important ones being:
Directed or Undirected
Weighted or Unweighted
Both Adjacency Matrix (AM) and Adjacency List (AL)
representations can be used for graphs – weighted
or unweighted, directed or undirected.
A[i,j] = A[j,i] if graph is undirected. So, we could decide to use
just the upper triangle.
If graph is weighted, in adjacency list, we can also store the
weight. AL[i] = [(j,w(i,j)), (k,w(i,k)), …]
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 11
GRAPH CHARACTERIZATIONS
12. A tree is a connected acyclic graph (i.e., it has no
cycles)
Rooted tree: A tree in which one node is designated
as a root (the top node)
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 12
TREE
Example:
Node A is root node
F and D are child nodes of A.
P and Q are child nodes of J.
Etc.
13. Definitions
Leaf is a node that has no children
Ancestors of a node x are all the nodes on the path from x to
the root, including x and the root
Subtree rooted at x is the tree consisting of x, its children and
their children, and so on and so forth all the way down
Height of a tree is the maximum distance from the root to any
node
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 13
TREE (CONT.)
14. Option 1
•Trees are
graphs, so we
can use
standard graph
representation
– Adjacency
Matrix or
Adjacency List
Option 2
•Use parent
node and list
for child nodes
Option 3
•Use parent
node, and two
pointers – one
for first child
and the other
for nextSibling
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 14
REPRESENTING TREES
3 Basic Options
15. We can use standard graph representation –
Adjacency Matrix or Adjacency List
These options are overkill for trees, but in some
instances, the graph is not known to be a tree
beforehand, so this option works.
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 15
TREE REPRESENTATION – OPTION 1
16. Rather than using Adjacency Matrix
or Adjacency List representation,
we can use a simpler representation
Each node has a pointer to parent,
and a linked list of child nodes
The root node’s parent pointer is null
This representation works for “rooted” trees. If the
tree is not rooted, we can designate one node as
root.
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 16
TREE REPRESENTATION – OPTION 2
Node {
Node parent,
List<Node> childNodes
}
17. Another representation for Trees: Left
Child, Right Sibling representation for a
tree. Each node has 3 pointers:
Parent – Points to parent (null if this is the root
node)
Left pointer – Points to first child (null if this is
a leaf node)
Right pointer – Points to right sibling (null if no
more siblings)
For example:
is represented by
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 17
TREE REPRESENTATION – OPTION 3
Node {
Node parent,
Node firstChild,
Node nextSibling
}
18. When updating values in a tree, such as the size of the
subtree rooted at a node, the weight of the subtree
rooted at a node, etc, there are two main methods:
Recompute whenever there is a modify operation (addition of a
node, deletion of a node, changing the weight of a node, etc).
Recomputations usually only need to propagate from the change
node upwards to the root. [Advantage: Values always up to date,
Disadvantages: Lot of time spent in Recompute, Method cannot
be run concurrently.]
Use a dirty flag and set to true when there is a change. Set dirty
flag to true for all ancestors (navigate to parent, until the root).
Recompute when there is a need, or as per a schedule.
[Advantages: Efficient, Methods (other than the “recomputed”
operation can be run concurrently. Disadvantages: Values are out
of date at times.]
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 18
UPDATING VALUES
19. Able to hold the entire graph in memory?
If your graph is large and changing fast, like the
Facebook interconnection graph, you simply cannot
hold it in memory using traditional methods. You
need to replicate it across multiple servers and use
reliable services to get partial data out from the
graph. Your graph may simply be backed by a
database with which you interact directly (without
ever loading a complete “graph” object.)
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 19
LARGE GRAPHS
20. Given each of the graph representations, how do we
find a path?
Shortest path algorithms
Dijkstra
All Pairs Shortest Paths
[Refer to CS 6212 Notes for details]
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 20
PATHS
21. Path, spread over time
Useful concept if the graph changes over time
Specifically, consider this scenario:
Edge e1 existed from x to y at time t1
Edge e2 existed from y to z at time t2
t1 < t2
Then, we say that there exists a journey from x to z
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 21
JOURNEY
22. How can we detect cycles in a graph?
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 22
CYCLES
23. Assuming a graph is a Directed Acyclic Graph,
topological ordering can be produced in linear time.
O(n + m)
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 23
TOPOLOGICAL SORTING
24. Graphs are important data structures with numerous
applications
Graphs can be of different kinds
Many convenient ways to model graphs
Adjacency Matrix
Adjacency List
Special structures for trees
Many commercial and open source libraries exist, such as
JGraphT
CS 6213 – Arora – L2 Advanced Data Structures - Graphs 24
SUMMARY