当前位置:网站首页>Draw a directed graph based on input
Draw a directed graph based on input
2022-07-01 06:28:00 【Keep--Silent】
List of articles
explain
Draw one directly from the input mermaid
Source code
#include <bits/stdc++.h>
using namespace std;
int main() {
int m, j,v,w,x;
map<int, map<int, int> >g;
cin >> m;
while (m--) {
cin >> v >> w >> x;
g[v][w] = x;
//g[w][v]=x;
}
set<int>st;
vector<int>t(3, 0);
vector<vector<int>>vt;
for (auto p1:g) {
st.insert(p1.first);
for (auto p2 : p1.second) {
st.insert(p2.first);
vt.push_back(vector<int>{
p1.first,p2.first,p2.second});
}
}
printf("```mermaid\ngraph TD\n");
for (auto x : st) {
printf("%d([%d])\n",x,x);
}
for (auto v : vt) {
printf("\t%d -->|%d| %d\n",v[0],v[2],v[1]);
}
printf("```\n");
return 0;
}
Input and output
7
1 2 2
1 5 1
2 3 1
2 4 1
2 5 2
3 5 1
3 4 1
```mermaid
graph TD
1([1])
2([2])
3([3])
4([4])
5([5])
1 -->|2| 2
1 -->|1| 5
2 -->|1| 3
2 -->|1| 4
2 -->|2| 5
3 -->|1| 4
3 -->|1| 5
```
effect
边栏推荐
- C语言课设学生考勤系统(大作业)
- 子类调用父类的同名方法和属性
- HCM Beginner (IV) - time
- [postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map
- C language course is provided with employee information management system (large operation)
- Excel visualization
- ManageEngine Zhuohao helps you comply with ISO 20000 standard (IV)
- Dongle data collection
- [summary of problem thinking] Why is the register reset performed in user mode?
- C语言课设学生选修课程系统(大作业)
猜你喜欢

C语言课设销售管理系统设计(大作业)
![[unity shader stroke effect _ case sharing first]](/img/bd/5cd1bef24e6b6378854114c2c05bd9.png)
[unity shader stroke effect _ case sharing first]

嵌入式系统
![[network security tool] what is the use of USB control software](/img/cc/20fc1f35c139c52c5922727368b835.png)
[network security tool] what is the use of USB control software

Forkjoin and stream flow test
![[postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map](/img/c0/299a406efea51f24b1701b66adc1e3.png)
[postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map

SQL语句

Record MySQL troubleshooting caused by disk sector damage

async 与 await

C language course is provided with employee information management system (large operation)
随机推荐
TCL statements in SQL (transaction control statements)
[self use of advanced mathematics in postgraduate entrance examination] advanced mathematics Chapter 1 thinking map in basic stage
C language course set up salary management system (big homework)
HCM Beginner (III) - quickly enter pa70 and pa71 to browse employee information PA10
做技术,自信不可或缺
Mysql 表分区创建方法
C language course set up property fee management system (big work)
子类调用父类的同名方法和属性
PAT (Advanced Level) Practice 1057 Stack
【ManageEngine卓豪】助力黄石爱康医院实现智能批量化网络设备配置管理
SQL学习笔记2
Application of IT service management (ITSM) in Higher Education
lxml模块(数据提取)
数据库产生死锁了请问一下有没有解决办法
连续四年入选Gartner魔力象限,ManageEngine卓豪是如何做到的?
给逆序对数求原数组
端口扫描工具对企业有什么帮助?
[unity shader amplify shader editor (ASE) Chapter 9]
mysql约束学习笔记
SQL statement