当前位置:网站首页>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
边栏推荐
- Treasure taking from underground palace (memory based deep search)
- PAT (Advanced Level) Practice 1057 Stack
- Mysql 表分区创建方法
- Recueillir des trésors dans le palais souterrain (recherche de mémoire profonde)
- @Transactional的传播属性REQUIRES_NEW深入理解
- [ManageEngine] terminal management system helps Huasheng securities' digital transformation
- 网络爬虫
- Although pycharm is marked with red in the run-time search path, it does not affect the execution of the program
- 第五章 输入/输出(I/O)管理
- 高阶-二叉搜索树详解
猜你喜欢

On siem

概率论学习笔记

HCM Beginner (II) - information type

sci-hub如何使用

C language course set up library information management system (big homework)
![[ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security](/img/fb/0a9f0ea72efc4785cc21fd0d4830c2.png)
[ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security

【企业数据安全】升级备份策略 保障企业数据安全

FPGA - 7 Series FPGA internal structure clocking-01-clock Architecture Overview

手把手教你实现一个深度学习框架...

【网络安全工具】USB控制软件有什么用
随机推荐
连续四年入选Gartner魔力象限,ManageEngine卓豪是如何做到的?
JMM详解
C language course set up property fee management system (big work)
C language course set up student elective course system (big homework)
SystemVerilog learning-07-class inheritance and package use
【ManageEngine】终端管理系统,助力华盛证券数字化转型
FPGA - clocking -02- clock wiring resources of internal structure of 7 Series FPGA
Restframework-simplejwt rewrite authentication mechanism
Dongle data collection
SQL statement
【Unity Shader 消融效果_案例分享】
[self use of advanced mathematics in postgraduate entrance examination] advanced mathematics Chapter 1 thinking map in basic stage
[ManageEngine] terminal management system helps Huasheng securities' digital transformation
[enterprise data security] upgrade backup strategy to ensure enterprise data security
C how to print out the original array
How does the port scanning tool help enterprises?
Internet worm
idea 好用插件汇总!!!
Minio error correction code, construction and startup of distributed Minio cluster
H5网页判断是否安装了某个APP,安装则跳转未安装则下载的方案总结