Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
32 views

Lec1 Graph

Here is the full adjacency list representation of the Seven Bridges of Königsberg graph: Vertices: A, B, C, D Edges: (A,B), (B,C), (C,D), (D,A), (A,C), (B,D), (C,A) Vertex pointers: A -> (A,B), (A,C), (C,A) B -> (B,C), (B,D) C -> (C,D), (B,C), (A,C) D -> (D,A), (C,D) Edge endpoints: (A,B) -> A, B

Uploaded by

Hà Vân
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Lec1 Graph

Here is the full adjacency list representation of the Seven Bridges of Königsberg graph: Vertices: A, B, C, D Edges: (A,B), (B,C), (C,D), (D,A), (A,C), (B,D), (C,A) Vertex pointers: A -> (A,B), (A,C), (C,A) B -> (B,C), (B,D) C -> (C,D), (B,C), (A,C) D -> (D,A), (C,D) Edge endpoints: (A,B) -> A, B

Uploaded by

Hà Vân
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Graph Theory and

Applications
Lecture 1: Introduction to Graph

Ta Viet Cuong, Ph.D


HMI laboratory, FIT-UET
Today
I. Course Overview
II. Graph definitions
a. Graph elements
b. Graph type
III. Graph Representation
IV. Graph Applications
V. Homework

2
Course Overview: First part
Review previous topics on Data Structures and Algorithms/Discrete Math

1. Graph search and its applications


2. Shortest path on weighted graph
3. Spanning Tree

3
Course Overview 2: Second part
Advanced topics in Graph: Maximum Flow and Graph Matching, Tree, TSP

4
Course Overview 3: Third part
More advanced topics on Graph:

1. Random Walk
2. Spectral Theory on Graph
3. Graph Neural Network

5
Timeline

5 weeks Mid-term Test Group Projects


6 weeks

Part 1: Basic Graph Algs Part 2: More Graph Algs Part 3: Advanced Topics

Grading Policy:

- Attendant + Quiz: 10%


- Mid-term: 30%
- Group Projects: 60%

6
Course overview: Graph Theory
+ The first part + second part: An advanced Data Structures and Algorithms course
- Understanding definitions and its applications
- Solve several problems
- Coding examples
- *Require* discrete math skills

7
Course overview: Graph Theory
+ The third part: 4th year course, related Machine Learning and Data Mining
- Get familiar with python and its libraries on graph analysis: networkx, pytorch-geometric
- Deep learning on graph
- Read papers/writing reports

Social Network Analysis with Networkx 8


Required Courses
+ Data Structure and Algorithms
- Most exercises require analysis several aspects of an algorithms/structures
- Find graph-based solutions to real world problems (problem solving)
+ Discrete math
- Prove some theorems
+ Linear Algebra
- We have special tools for graph analysis: spectral theorem
+ AI/Machine Learning:
- Everything connect to AI now
- Mostly on graph neural networks, graph representation learning
- It is not a hard requirement

9
Course overview
Lecturer: Ta Viet Cuong, Ph. D (email: cuongtv@vnu.edu.vn)

- Teaching courses: Algorithms, AI, Machine Learning, Image Processing/Computer


Vision

Teaching Assistant: Kieu Hai Dang, MsC (email: dangkh_95@vnu.edu.vn)

- Mainly work on Advanced Algorithms

Contact: HMI laboratory, room 307, E3

10
Research Directions on Graph
Focus on: Machine Learning/Deep Learning for Graph-based Data. Why?

Since 2022: Recently advances on AI topics

- 2012: AlexNet on Image Data


- 2017: Transformer on Text Data
- Next: maybe Graph Data

Others:

- Google is based on the PageRank algorithm


- Facebook mainly virtualizes real-world connections
11
Research Directions on Graph
Our group focus on Learning Efficient Graph Embedding Models - “Mapping graph
vertices to a low dimensional space which preserves important structures of the graph”

- Mostly work on Transformer-based models until now


- Need strong engineer background students to extend the works

12
Research at HMI lab
Engineer:

- Tracking through multiple cameras


- Text generation applications on
GPT-based models
- Mining on Large/Dynamic Graph data
- Virtual Reality
- EEG/Eye tracking
- Document Analysis

13
Research at HMI lab
Engineer: Theory:

- Tracking through multiple cameras - Deep learning on graph


- Text generation applications on - Reinforcement learning in multi-agent
GPT-based models environment
- Mining on Large/Dynamic Graph data - Privacy-preserving machine learning
- Virtual Reality - Model compression
- EEG/Eye tracking - Few-shot Learning
- Document Analysis

14
Introduction to Graph
I. Course Overview
II. Graph definitions
a. Graph elements
b. Graph type
III. Graph Representation
IV. Graph Applications
V. Homework

15
Graph Definition
A graph represent G = <V, E> with:
V= - N vertices
E= - M edges
Each represents a connection
between 2 vertices

Fig 1. Seven Bridges of Königsberg and


its graph representation 16
Graph Definition
Another example: G = <V, E>

V = {A, B, C, D, E}

E = {(A, B), (A, B), (B, E), (A, C)

(C, D), (B, D), (D, E)}

Fig 2. Graph with 5 vertices and 7 edges

17
Graph Terminology
V - Vertices:

- Represent a single data element


- In general, {A, B, C, …} or {v_1, v_2, …., v_N}
- Has many interpretations: places, people, items, documents, objects, …

E - Edges:

- Modeling the relationship between two single data element


- Encode the local information - The most basic information about the graph

18
Graph Type: Undirected vs Directed
Based on the properties of edges: Is (A, B) the same as (B, A) ?

Fig 3a. Undirected Graph Fig 3b. Directed Graph

Examples: Friends, 2-way streets Examples: Liked, 1-way streets

19
Graph Type: no-weight vs weighted
Based on attributes of edge: it is associated with a number

- The most popular attribute: Weight/Length/Cost

Fig 4a. Graph Fig 4a. Weighted Graph

20
Other types of graph

Fig 5. Example of weighted graphs


21
Other types of graph
- Simple Graph: we mostly study on this one
- Tree: Connected graph with no-cycle
- Binary Graph
- Completed Graph
- Planar/Non Planar Graph
- Cycle Graph
- Line Graph
- Star Graph

22
Other types of edges
From theory aspect, there are other properties of E which could raise major issues:

Self-loop Edges Negative Edges Parallel Edges/

Multiple Edges
Fig 5. Special edge types
23
Introduction to Graph
I. Course Overview
II. Graph definitions
a. Graph elements
b. Graph type
III. Graph Representation
IV. Graph Applications
V. Homework

24
Adjacency Matrix
Let G = <V, E> with N vertices, M edges. Assume the vertices is 1, 2, .., N.
The adjacency matrix representation of G is a square NxN matrix A

With undirected graph:


Aij = Aji
deg(i) = sum of row ith

25
Example 1
Example with V = {A, B, C, D, E} and self-loop edge

Quiz 1. Could you draw the Seven Bridges of Königsberg graph?

Quiz 2. Could you verify that the smallest eigenvalues of A is zero if G is connected?

26
Example 2
The matrix is not symmetric anymore:

deg+(i) = sum of row i

deg-(i) = sum of column i

27
Computational Analysis: Adjacency Matrix
Memory Complexity: O(NxN)

Time Complexity:

- Verify that A, B connected to each other?


- Compute the degree of A?
- Delete/Add an edge ?
- Print the list neighbours of A?
- Print the list neighbours of neighbours of A ?
- Print the list of vertices could reach A ?

28
Adjacency List - Short version
Store the list of vertices could reach from a vertices A

Quiz 3: Fill the row of 3?


29
Computational Analysis: Adjacency List
Memory Complexity: O(M)

Time Complexity:

- Verify that A, B connected to each other?


- Compute the degree of A?
- Delete/Add an edge ?
- Print the list neighbours of A?
- Print the list neighbours of neighbours of A ?
- Print the list of vertices could reach A ?

30
Adjacency List - Full version
1. An array containing the graph’s vertices

2. An array containing the graph’s edges

3. For each edge, a pointer to each of its two endpoints.

4. For each vertex, a pointer to each of the incident edges.

In short: two lists and a lot of pointers

Quiz: Draw the full version of the Seven Bridges of Königsberg


31
Adjacency Matrix and Adjacency List
Directed Graph

32
Adjacency Matrix and Adjacency List
Undirected Graph

33
Adjacency Matrix and Adjacency List
Weighted version

34
Edges list
Intuition: the more we store, the more trouble when we need to updates

Let keep only a list of E:

Memory Complexity: O(M)

Time Complexity:

- Verify that A, B connected to each other?


- Compute the degree of A?
- Delete/Add an edge ?
- Print the list neighbours of A?
- Print the list neighbours of neighbours of A ?
- Print the list of vertices could reach A ?
35
Graph Type: Sparse vs Dense Graph
Graph density = comparing N - number of vertices, M - number of edges:

- M ~ NlogN: Sparse graph


- M ~ N2logN: Dense graph

36
Introduction to Graph
I. Course Overview
II. Graph definitions
a. Graph elements
b. Graph type
III. Graph Representation
IV. Graph Applications
V. Homework

37
Graph Applications 1
Road networks: K-Connected roads, Shortest path/Fastest path, Planning/Routing

38
Graph Applications 2
Social Network applications (see Homework 2):

- Which one are directed graphs/undirected graphs?

39
Graph Applications 3
Image analysis with graph

40
Homework 1:
Prove or disapprove following statements:
1. Given a connected, simple, undirected graph, we have:

2. is even, for any G without loop-edges

41
Homework 2: Dynamic Social Graph
Given a undirected graph G = <V, E>.
- We define the L1(v) is the set of friends, L2(v) is the set of nodes can reach from v with two-steps propagation,
and not belong to L1(v) - friends of friends.
- We also define a closeness measure between two nodes u, v:

- G have dynamic edges, i.e edges are updated frequently including adding and deleting.
Tasks: With each v, we want to extract the first K - largest values d(u, v) with u in L2(v). How do you store G if:
a) G is a dense graph
b) G is a sparse graph
c) G is an “almost sparse graph”, a small amount of nodes (1-2%) have much bigger degrees than the others

42

You might also like