图形由顶点/节点和连接这些顶点的边/线组成。

图可以是无向的(意味着在与每个双向边相关联的两个顶点之间没有区别)或者可以指向图(意味着其边缘从一个顶点指向另一个顶点但不一定在另一个方向上)。

可以对图形进行加权(通过向每个边缘分配权重,其表示与该连接相关联的数值)或者图形可以是未加权的(所有边缘具有单位权重1或者所有边缘具有相同的恒定权重)。

Remarks: By default, we show e-Lecture Mode for first time (or non logged-in) visitor.
If you are an NUS student and a repeat visitor, please login.

🕑
我们在VisuAlgo中讨论的大多数图形问题都涉及简单图

在一个简单图中,没有(自 - )环边(连接顶点与自身的边),没有多边/平行边(同一对顶点之间的边)。换句话说:在一对不同的顶点之间最多只能有一条边。

简单图中的边E的数量范围仅为0到O(V2)。

简单图上的图算法比非简单图上的算法更容易。

Pro-tip 1: Since you are not logged-in, you may be a first time visitor (or not an NUS student) who are not aware of the following keyboard shortcuts to navigate this e-Lecture mode: [PageDown]/[PageUp] to go to the next/previous slide, respectively, (and if the drop-down box is highlighted, you can also use [→ or ↓/← or ↑] to do the same),and [Esc] to toggle between this e-Lecture mode and exploration mode.

🕑

在无向边e:(uv)中,我们称其与两个端点顶点:uv相邻。如果两个顶点与一个公共边相邻,我们称它们为相邻(或邻居)。例如,边 (0, 2) 与顶点 0+2 相邻,顶点 0+2 是相邻的。


如果两条边与一个公共顶点相邻,我们称它们为相邻。例如,边 (0, 2) 和 (2, 4) 是相邻的。


在无向图中,顶点v的度是与顶点v相邻的边的数量。度为0的顶点被称为孤立顶点。例如,顶点 0/2/6 的度分别为 2/3/1。


G的子图G'是一个包含G的顶点和边的子集的(较小的)图。例如,三角形 {0, 1, 2} 是当前显示图的子图。


Pro-tip 2: We designed this visualization and this e-Lecture mode to look good on 1366x768 resolution or larger (typical modern laptop resolution in 2021). We recommend using Google Chrome to access VisuAlgo. Go to full screen mode (F11) to enjoy this setup. However, you can use zoom-in (Ctrl +) or zoom-out (Ctrl -) to calibrate this.

🕑
(无向)图G中(长度为n)的路径是顶点序列{v0,v1,...,vn-1,vn},使得在vivi+1∀i∈[0..n-1]之间存在边缘。
如果路径上没有重复的顶点,我们称这样的路径为简单路径。
例如,{0,1,2,4,5}是当前显示的图形中的一个简单路径。

Pro-tip 3: Other than using the typical media UI at the bottom of the page, you can also control the animation playback using keyboard shortcuts (in Exploration Mode): Spacebar to play/pause/replay the animation, / to step the animation backwards/forwards, respectively, and -/+ to decrease/increase the animation speed, respectively.

🕑

An undirected graph G is called connected if there is a path between every pair of distinct vertices of G. For example, the currently displayed graph is not a connected graph.


An undirected graph C is called a connected component of the undirected graph G if:
1). C is a subgraph of G;
2). C is connected;
3). no connected subgraph of G has C as a subgraph and contains vertices or edges that are not in C (i.e., C is the maximal subgraph that satisfies the other two criteria).


For example, the currently displayed graph have {0, 1, 2, 3, 4} and {5, 6} as its two connected components.


A cut vertex/bridge is a vertex/edge that increases the graph's number of connected components if deleted. For example, in the currently displayed graph, there is no cut vertex, but edge (5, 6) is a bridge.

🕑

In a directed graph, some of the terminologies mentioned earlier have small adjustments.


If we have a directed edge e: (uv), we say that v is adjacent to u but not necessarily in the other direction. For example, 1 is adjacent to 0 but 0 is not adjacent to 1 in the currently displayed directed graph.


In a directed graph, we have to further differentiate the degree of a vertex v into in-degree and out-degree. The in-degree/out-degree is the number of edges coming-into/going-out-from v, respectively. For example, vertex 1 has in-degree/out-degree of 2/1, respectively.

🕑

In a directed graph, we extend the concept of Connected Component (CC) into Strongly Connected Component (SCC). A directed graph G is called strongly connected if there is a path in each direction between every pair of distinct vertices of G.


A directed graph SCC is called a strongly connected component of the directed graph G if:
1). SCC is a subgraph of G;
2). SCC is strongly connected;
3). no connected subgraph of G has SCC as a subgraph and contains vertices or edges that are not in SCCC (i.e., SCC is the maximal subgraph that satisfies the other two criteria).


In the currently displayed directed graph, we have {0}, {1, 2, 3}, and {4, 5, 6, 7} as its three SCCs.

🕑

一个循环是一条起始和结束于同一顶点的路径。


一个无环图是一个不包含任何循环的图。


在一个无向图中,每一条无向边都会形成一个平凡的循环(长度为2),尽管我们通常不会将其分类为循环。


一个同时也是无环的有向图有一个特殊的名字:有向无环图(DAG),如上图所示。


我们可以在无环图上执行一些有趣的算法,这将在这个可视化页面和VisuAlgo的其他图形可视化页面中进行探索。

🕑
具有涉及其顶点和/或边结构的特定属性的图可以使用其特定名称来调用,如树(如当前所示),完整图,二分图,有向无环图(DAG),以及使用频率较低的图:平面图,线图,星图,轮图等

在此可视化中,我们将在稍后突出显示前四个特殊图表。
🕑
图表在现实生活中经常以各种形式出现。因此,解决图形问题的最重要部分是图形建模部分,即将手中的问题简化为图形术语:顶点,边,权重等。
🕑
社交网络:顶点可以代表人,边缘代表人与人之间的联系(通常是无向和未加权)。

例如,请参阅当前显示的无向图。此图显示了它们之间的7个顶点(人)和8个边(连接/关系)。也许我们可以提出这样的问题:

谁是0的人的朋友?
谁拥有最多的朋友?
有没有孤立的人(那些没有朋友的人)?
两个陌生人之间是否有共同的朋友:3号人和5号人?
等等...
🕑
运输网络:顶点可以表示站点,边缘表示站点之间的连接(通常是加权的)。

例如,请参阅当前显示的有向加权图。该图显示了5个顶点(站点/位置)和6个边缘(站点之间的连接/道路,具有正的权重行进时间,如图所示)。假设我们正在开车。我们或许可以问一下从0号站到4号站的路径是什么,以便我们用最少的时间到达4号站?

讨论:想想其他一些可以建模为图形的现实生活场景。
🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

要在图形绘制模式之间切换,请选择相应的标题。 我们有:

  1. U/U = 无向/不加权,
  2. U/W = 无向/加权,
  3. D/U = 有向/不加权, and
  4. D/W = 有向/加权.

我们根据所选模式限制您可以绘制的图形类型。

🕑

您可以点击任何一个示例图,并查看其示例图绘制,这是该图的二维描述。请注意,同一图可以有(无限)多种可能的图绘制。


您可以通过点击 "编辑图" 进一步编辑(添加/删除/重新定位顶点或添加/更改权重/删除边)当前显示的图(在编辑图窗口中阅读相关的帮助信息)。

🕑

我们将 VisuAlgo 中讨论的图限制为简单图。请参考这个幻灯片中的讨论。


虽然现在我们并没有真正限制你可以在屏幕上绘制的顶点数量,但我们建议你不要绘制超过10个顶点,范围从顶点0到顶点9(因为这个图的邻接矩阵已经包含10x10 = 100个单元格)。这与前面的简单图约束一起,限制了无向/有向边的数量分别为45/90。

🕑

所有示例图都可以在这里找到。我们为每个类别(U/U,U/W,D/U,D/W)提供七个“最相关”的示例图。


请记住,加载这些示例图之一后,您可以进一步编辑当前显示的图以适应您的需求。

🕑

树,完全图,二部图,有向无环图 (DAG) 是特殊图的属性。当你编辑图时,这些属性会被立即检查和更新。


还有其他不常用的特殊图:平面图,线图,星图,轮图等,但在这个可视化中,它们目前还不能被自动检测。

🕑

是一个具有V个顶点和E = V-1条边的连通图,无环,并且任意两个顶点之间有一个唯一的路径。通常,树是在无向图上定义的。


一个无向树(如上所述)实际上包含了平凡的循环(由其双向边引起),但它不包含非平凡的循环(长度为3或更大)。一个有向树显然是无环的。


由于树只有V-1条边,它通常被认为是一个稀疏图。


我们目前展示的是U/U: 树的例子。你可以进入'探索模式'并编辑/绘制你自己的树。

🕑

并非所有的树都有相同的图形绘制布局,即顶部有一个特殊的根顶点,底部有叶顶点(度为1的顶点)。上面显示的(星形)图也是一棵树,因为它满足树的属性。


将其中一个顶点指定为根顶点的树被称为有根树。


我们总是可以通过指定一个特定的顶点(通常是顶点0)为根,然后从根运行DFS 或 BFS 算法,将任何树转化为有根树。这个"根化树"的过程(对于一个还没有被视觉化绘制为树的树)有一个视觉解释。想象每个顶点是一个小球(有非零的重量),每条边是一条相同长度的绳子,连接两个相邻的球。现在,如果我们拿起根球/顶点并将其拉起,那么重力将拉动其余的球向下,这就是树的DFS/BFS生成树。

🕑

在一个有根树中,我们有层级(父节点,子节点,祖先,后代),子树,层次和高度的概念。我们将通过例子来说明这些概念,因为它们的含义与现实生活中的对应物一样:

  1. 0/1/7/9/4的父节点分别是无/0/1/8/3,
  2. 0/1/7的子节点分别是 {1,8}/{2,3,6,7}/无,
  3. 4/6/8的祖先分别是 {3,1,0}/{1,0}/{0},
  4. 4和6的最低公共祖先是1。
  5. 1/8的后代分别是 {2,3,4,5,6,7}/{9},
  6. 以1为根的子树包括1,它的后代和所有相关的边,
  7. 0/1/2/3级成员分别是 {0}/{1,8}/{2,3,6,7,9}/{4,5},
  8. 这个有根树的高度是它的最大层级 = 3。
🕑
对于有根树,我们还可以定义其他属性:
二叉树是一个有根树,其中一个顶点最多有两个孩子,它们被恰当地命名为:left和right child(左子节点和右子节点)。在讨论二叉搜索树二叉堆时,我们经常会看到这种形式。
满二叉树是一个其中每个非叶(也称为内部)顶点恰好有两个子节点的二叉树。上面显示的二叉树符合此标准。
一个完全二叉树的每个级别都被完全填充,除了最后一级可能尽可能地填充。我们经常会在讨论二叉堆时看到这种形式。
🕑

完全图是一个具有V个顶点和E = V*(V-1)/2条边的图(或E = O(V2)),即,任何一对顶点之间都有一条边。我们用KV表示具有V个顶点的完全图。


完全图是最密集的简单图。


我们目前展示的是U/W: K5 (Complete)示例。你可以进入'探索模式'并编辑/绘制你自己的完全图(尽管对于较大的V来说有点繁琐)。

🕑

二部图是一个无向图,具有V个顶点,可以划分为两个大小为mn的不相交顶点集,其中V = m+n。同一集合的成员之间没有边。二部图也不包含奇数长度的循环。


我们目前展示的是U/U: 二部图示例。你可以进入'探索模式'并绘制/编辑你自己的二部图。


二部图也可以是完全的,即,一个不相交集合中的所有m个顶点都与另一个不相交集合中的所有n个顶点相连。当m = n = V/2时,这样的完全二部图也有E = O(V2)。


树也是二部图,即,所有在偶数级别的顶点形成一个集合,所有在奇数级别的顶点形成另一个集合。

🕑

有向无环图 (DAG) 是一种没有循环的有向图,这对于动态规划 (DP) 技术非常相关。


每个 DAG 都至少有一个拓扑排序/顺序,可以通过对 DFS/BFS 图遍历算法的简单调整找到。在DP 技术用于 DAG 上的 SSSP中,我们将再次访问 DAG。


我们目前展示了我们的D/W:四个 0→4 路径示例。你可以进入'探索模式'并绘制你自己的 DAGs。

🕑
有许多方法可以将图形信息存储到图形数据结构中。在此可视化中,我们显示了三个图形数据结构:邻接矩阵,邻接列表和边缘列表 - 每个都有自己的优点和缺点。
🕑

邻接矩阵 (AM) 是一个方阵,其中条目 AM[i][j] 显示从顶点 i 到顶点 j 的边的权重。对于无权图,我们可以为所有边的权重设置单位权重 = 1。


我们通常设置 AM[i][j] = 0 来表示没有边 (i, j)。然而,如果图包含0权重的边,我们必须使用另一个符号来表示“无边”(例如,-1,None,null,等等)。


我们简单地使用一个 C++/Python/Java 原生的 2D 数组/列表,大小为 VxV 来实现这个数据结构。

🕑
空间复杂度分析:不幸的是,AM需要O(V2)的大空间复杂度,即使图形实际上是稀疏的(边缘不多)。

讨论:了解AM的大空间复杂性,何时使用它是有益的?或者AM总是一个劣质的图形数据结构,永远不该使用?
🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑
邻接列表(AL)是有V个列表的数组,每个顶点一个(通常以递增的顶点数排序),其中对于每个顶点i,AL [i]存储i的邻居列表。对于加权图,我们可以存储(邻居顶点,此边的权重)对。
我们使用一个嵌套的Vector对(用于加权图)来实现此数据结构。在C++中:vector<vector<pair<int, int>>> AL; Python: AL = [[] for _ in range(N)] Java: Vector<Vector<IntegerPair>> AL; // Java 中的IntegerPair 类似于 C++中的pair<int, int>
🕑
class IntegerPair implements Comparable<IntegerPair> {
Integer _f, _s;
public IntegerPair(Integer f, Integer s) { _f = f; _s = s; }
public int compareTo(IntegerPair o) {
if (!this.first().equals(o.first())) // this.first() != o.first()
return this.first() - o.first(); // is wrong as we want to
else // compare their values,
return this.second() - o.second(); // not their references
}
Integer first() { return _f; }
Integer second() { return _s; }
}
// IntegerTriple is similar to IntegerPair, just that it has 3 fields
🕑

我们使用对因为我们需要为每条边存储一对信息:(邻接顶点编号,边权重),其中权重字段可以设置为1,0,未使用,或者对于无权图简单地丢弃。


我们使用对的向量,因为向量具有自动调整大小的特性。如果我们有一个顶点的k个邻居,我们只需向这个顶点的初始为空的对的向量中添加k次(这个向量可以用链表替换)。


我们使用对的向量的向量,因为向量具有索引特性,即,如果我们想要枚举顶点u的邻居,我们使用 AL[u] (C++/Python) 或 AL.get(u) (Java) 来访问正确的对的向量。

🕑
空间复杂度分析:AL具有O(V + E)的空间复杂度,比AM效率高得多,并且通常是大多数图形算法中的默认图形数据结构。
讨论:AL是最常用的图形数据结构,但讨论AL哪种情况实际上不是最佳的图形数据结构?
🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

边缘列表(EL)是具有连接顶点及其权重的边的集合。通常,这些边是按权重增加来排序的,例如, Kruskal's algorithm的一部分用于最小生成树(MST)的问题。但是,在此可视化中,我们通过增加第一个顶点数来对边进行排序,如果是连接,则通过增加第二个顶点数来对边进行排序请注意,无向/有向图中的双向边分别列出一次/两次。
我们使用三元组Vector来实现这种数据结构。C++:vector<tuple<int, int, int>> EL; Python: EL = [] Java: Vector<IntegerTriple> EL; // Java中的IntegerTriple类似于C++中的tuple<int, int, int>

🕑
空间复杂度分析:EL具有O(E)的空间复杂度,其比AM更有效并且与AL一样有效。

讨论:除了Kruskal的最小生成树(MST)算法之外,详细说明EL的潜在用法!
🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

将图形信息存储到图形数据结构后,我们可以回答几个简单的问题。

  1. 计数 V,
  2. 计数 E,
  3. 枚举顶点u的邻居,
  4. 检查边缘(u,v)的存在等。
🕑
在AM和AL中,V只是数据结构的行数,可以在O(V中或甚至在O(1中获得 - 取决于实际实现。
讨论:如果图存储在EL中,如何计算V
PS:有时这个数字是存储/维护在一个单独的变量中,这样我们就不必每次都重新计算它 - 特别是如果图形在创建之后永远/很少改变,因此我们有O(1)性能,例如:对于上面显示的示例图,我们可以存储(在我们的AM / AL / EL数据结构中)有7个顶点。
🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

In an EL, E is just the number of its rows that can be counted in O(E) or even in O(1) — depending on the actual implementation. Note that depending on the need, we may store a bidirectional edge just once in the EL but on other case, we store both directed edges inside the EL.


In an AL, E can be found by summing the length of all V lists and divide the final answer by 2 (for undirected graph). This requires O(V+E) computation time as each vertex and each edge is only processed once. This can also be implemented in O(V) in some implementations.


Discussion: How to count E if the graph is stored in an AM?


PS: Sometimes this number is stored/maintained in a separate variable for efficiency, e.g., we can store that there are 8 undirected edges (in our AM/AL/EL data structure) for the example graph shown above.

🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑
在AM中,如果AM [u],我们需要遍历AM [u] [j]∀j∈[0..V-1]的所有列并报告(j,AM [u] [j])是否[j]是零。这是 O(V) - 慢。
在AL中,我们只需要遍历AL [u]。如果顶点u只有k个邻居,那么我们只需要O(k来枚举它们 - 这被称为输出敏感时间复杂度,已经是最好的了。
我们通常按顶点数量递增的方式列出邻居。例如,上面的示例图中的顶点1的邻居是{0,2,3},按增加的顶点数顺序。
讨论:如果图形存储在EL中,如何执行此操作?
🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑
在AM中,我们可以简单地检查AM [u] [v]是否为非零。这是O(1) - 最快的。
在AL中,我们必须检查AL [u]是否包含顶点v。这是O(k) - 更慢。
例如,上面的示例图中存在边(2,4),但边不存在边(2,6)。
请注意,如果我们找到了edge(u,v),我们也可以访问和/或更新其权重。
讨论:如果图形存储在EL中,如何执行此操作?
🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

Quiz: So, what is the best graph data structure?

Edge List
Adjacency Matrix
Adjacency List
It Depends

讨论: 为什么?

🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

您已经学完了这个相对简单的图形数据结构的基础内容,我们鼓励您在探索模式中进一步探索,通过编辑当前绘制的图形,绘制您自己的自定义图形,或者输入边缘列表/邻接矩阵/邻接列表输入,并要求 VisuAlgo 提出一个"足够好"的输入图形的绘制。


然而,我们还有一些更有趣的图形数据结构挑战等待着您,在本节中进行了概述。


请注意,图形数据结构通常只是解决更难的图形问题的必要条件,但不是充分条件,如MSTSSSPMFMatchingMVCST,或TSP

🕑

有关此数据结构的一些有趣问题,请练习Graph Data Structures培训模块(无需登录)。

🕑
请查看 C++/Python/Java/OCaml 对于此课中讲到的这三种图结构的实现:邻接矩阵(Adjacency Matrix),邻接表(Adjacency List),边表(Edge List):graph_ds.cpp | py | java | ml.
🕑

尝试解决两个基本的编程问题,这些问题需要使用图形数据结构,而不需要任何花哨的图形算法:

  1. UVa 10895 - Matrix Transpose and,
  2. Kattis - flyingsafely.
🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

Last but not least, there are some graphs that are so nicely structured that we do not have to actually store them in any graph data structure that we have discussed earlier.


For example, a complete unweighted graph can be simply stored with just one integer V, i.e., we just need to remember it's size and since a complete graph has an edge between any pair of vertices, we can re-construct all those V * (V-1) / 2 edges easily.


Discussion: Can you elaborate a few more implicit graphs?

🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.


You have reached the last slide. Return to 'Exploration Mode' to start exploring!

Note that if you notice any bug in this visualization or if you want to request for a new visualization feature, do not hesitate to drop an email to the project leader: Dr Steven Halim via his email address: stevenhalim at gmail dot com.

🕑
V=0, E=0 • 树? No • 完成? No • 二部? No • DAG? No • 交叉? No
邻接矩阵
012
0010
1101
2010
邻接列表
0: 1
1: 02
2: 1
边缘列表
0: 01
1: 12

编辑图表

>
关于 团队 使用条款
隐私政策

关于

VisuAlgo最初由副教授Steven Halim于2011年构思,旨在通过提供自学、互动式学习平台,帮助学生更深入地理解数据结构和算法。

VisuAlgo涵盖了Steven Halim博士与Felix Halim博士、Suhendry Effendy博士合著的书《竞技编程》中讨论的许多高级算法。即使过去十年,VisuAlgo仍然是可视化和动画化这些复杂算法的独家平台。

虽然VisuAlgo主要面向新加坡国立大学(NUS)的学生,包括各种数据结构和算法课程(例如CS1010/等价课程,CS2040/等价课程(包括IT5003),CS3230,CS3233和CS4234),但它也是全球好奇心的宝贵资源,促进在线学习。

最初,VisuAlgo并不适用于智能手机等小触摸屏,因为复杂的算法可视化需要大量的像素空间和点击拖动交互。为了获得最佳用户体验,建议使用最低分辨率为1366x768的屏幕。然而,自2022年4月以来,VisuAlgo的移动(精简)版本已经推出,使得在智能手机屏幕上使用VisuAlgo的部分功能成为可能。

VisuAlgo仍然在不断发展中,正在开发更复杂的可视化。目前,该平台拥有24个可视化模块。

VisuAlgo配备了内置的问题生成器和答案验证器,其“在线测验系统”使学生能够测试他们对基本数据结构和算法的理解。问题根据特定规则随机生成,并且学生提交答案后会自动得到评分。随着越来越多的计算机科学教师在全球范围内采用这种在线测验系统,它可以有效地消除许多大学标准计算机科学考试中手工基本数据结构和算法问题。通过给通过在线测验的学生分配一个小但非零的权重,计算机科学教师可以显著提高学生对这些基本概念的掌握程度,因为他们可以在参加在线测验之前立即验证几乎无限数量的练习题。每个VisuAlgo可视化模块现在都包含自己的在线测验组件。

VisuAlgo已经被翻译成三种主要语言:英语、中文和印尼语。此外,我们还用各种语言撰写了关于VisuAlgo的公开笔记,包括印尼语、韩语、越南语和泰语:

id, kr, vn, th.

团队

项目领导和顾问(2011年7月至今)
Associate Professor Steven Halim, School of Computing (SoC), National University of Singapore (NUS)
Dr Felix Halim, Senior Software Engineer, Google (Mountain View)

本科生研究人员 1
CDTL TEG 1: Jul 2011-Apr 2012: Koh Zi Chun, Victor Loh Bo Huai

最后一年项目/ UROP学生 1
Jul 2012-Dec 2013: Phan Thi Quynh Trang, Peter Phandi, Albert Millardo Tjindradinata, Nguyen Hoang Duy
Jun 2013-Apr 2014 Rose Marie Tan Zhao Yun, Ivan Reinaldo

本科生研究人员 2
CDTL TEG 2: May 2014-Jul 2014: Jonathan Irvin Gunawan, Nathan Azaria, Ian Leow Tze Wei, Nguyen Viet Dung, Nguyen Khac Tung, Steven Kester Yuwono, Cao Shengze, Mohan Jishnu

最后一年项目/ UROP学生 2
Jun 2014-Apr 2015: Erin Teo Yi Ling, Wang Zi
Jun 2016-Dec 2017: Truong Ngoc Khanh, John Kevin Tjahjadi, Gabriella Michelle, Muhammad Rais Fathin Mudzakir
Aug 2021-Apr 2023: Liu Guangyuan, Manas Vegi, Sha Long, Vuong Hoang Long, Ting Xiao, Lim Dewen Aloysius

本科生研究人员 3
Optiver: Aug 2023-Oct 2023: Bui Hong Duc, Oleh Naver, Tay Ngan Lin

最后一年项目/ UROP学生 3
Aug 2023-Apr 2024: Xiong Jingya, Radian Krisno, Ng Wee Han

List of translators who have contributed ≥ 100 translations can be found at statistics page.

致谢
NUS教学与学习发展中心(CDTL)授予拨款以启动这个项目。在2023/24学年,Optiver的慷慨捐赠将被用来进一步开发 VisuAlgo。

使用条款

VisuAlgo慷慨地向全球计算机科学界提供免费服务。如果您喜欢VisuAlgo,我们恳请您向其他计算机科学学生和教师宣传它的存在。您可以通过社交媒体平台(如Facebook、YouTube、Instagram、TikTok、Twitter等)、课程网页、博客评论、电子邮件等方式分享VisuAlgo。

数据结构与算法(DSA)的学生和教师可以直接在课堂上使用本网站。如果您从本网站截取屏幕截图或视频,可以在其他地方使用,但请引用本网站的URL(https://visualgo.net)和/或下面的出版物列表作为参考。但请不要下载VisuAlgo的客户端文件并将其托管在您的网站上,因为这构成了抄袭行为。目前,我们不允许他人分叉此项目或创建VisuAlgo的变体。个人使用离线副本的客户端VisuAlgo是可以接受的。

请注意,VisuAlgo的在线测验组件具有重要的服务器端元素,保存服务器端脚本和数据库并不容易。目前,普通公众只能通过“培训模式”访问在线测验系统。“测试模式”提供了一个更受控制的环境,用于在新加坡国立大学的真实考试中使用随机生成的问题和自动验证。


出版物列表

这项工作曾在2012年国际大学生程序设计竞赛(波兰,华沙)的CLI研讨会上和2012年国际信息学奥林匹克竞赛(意大利,锡尔米奥内-蒙蒂基亚里)的IOI会议上展示过。您可以点击此链接阅读我们2012年关于该系统的论文(当时还没有称为VisuAlgo),以及此链接阅读2015年的简短更新(将VisuAlgo与之前的项目关联起来)。


错误报告或新功能请求

VisuAlgo并不是一个完成的项目。Steven Halim副教授仍在积极改进VisuAlgo。如果您在使用VisuAlgo时发现任何可视化页面/在线测验工具中的错误,或者您想要请求新功能,请联系Steven Halim副教授。他的联系方式是将他的名字连接起来,然后加上gmail dot com。

隐私政策

版本 1.2 (更新于2023年8月18日星期五)。

自2023年8月18日(星期五)起,我们不再使用 Google Analytics。因此,我们现在使用的所有 cookies 仅用于此网站的运营。即使是首次访问的用户,烦人的 cookie 同意弹窗现在也已关闭。

自2023年6月7日(星期五)起,由于 Optiver 的慷慨捐赠,全世界的任何人都可以自行创建一个 VisuAlgo 账户,以存储一些自定义设置(例如,布局模式,默认语言,播放速度等)。

此外,对于 NUS 学生,通过使用 VisuAlgo 账户(一个 NUS 官方电子邮件地址,课堂名册中的学生姓名,以及在服务器端加密的密码 - 不存储其他个人数据),您同意您的课程讲师跟踪您的电子讲义阅读和在线测验培训进度,这是顺利进行课程所必需的。您的 VisuAlgo 账户也将用于参加 NUS 官方的 VisuAlgo 在线测验,因此,将您的账户凭据传递给他人代您进行在线测验构成学术违规。课程结束后,您的用户账户将被清除,除非您选择保留您的账户(OPT-IN)。访问完整的 VisuAlgo 数据库(包含加密密码)的权限仅限于 Halim 教授本人。

对于全球其他已经给 Steven 写过信的 CS 讲师,需要一个 VisuAlgo 账户(您的(非 NUS)电子邮件地址,您可以使用任何显示名称,以及加密密码)来区分您的在线凭据与世界其他地方。您的账户将具有 CS 讲师特定的功能,即能够查看隐藏的幻灯片,这些幻灯片包含了在隐藏幻灯片之前的幻灯片中提出的问题的(有趣的)答案。您还可以访问 VisuAlgo 在线测验的 Hard 设置。您可以自由地使用这些材料来增强您的数据结构和算法课程。请注意,未来可能会有其他 CS 讲师特定的功能。

对于任何拥有 VisuAlgo 账户的人,如果您希望不再与 VisuAlgo 工具有关联,您可以自行删除您的账户。