Skip to content

Commit 80cae34

Browse files
authored
Merge pull request #59 from DMU-DebugVisual/inseong
시각화 예제추가
2 parents 230c927 + 0a01ee4 commit 80cae34

File tree

1 file changed

+217
-0
lines changed

1 file changed

+217
-0
lines changed

src/components/ide/IDE.jsx

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,224 @@ const IDE = () => {
519519
]
520520
}, null, 2),
521521
type: "json"
522+
},
523+
{
524+
name: "graph.json",
525+
code: JSON.stringify({
526+
"algorithm": "graph",
527+
"lang": "c",
528+
"input": "",
529+
"variables": [
530+
{ "name": "g", "type": "graph", "initialValue": "empty", "currentValue": "adjacency matrix filled" }
531+
],
532+
"functions": [
533+
{ "name": "init", "params": ["g"], "called": 1 },
534+
{ "name": "insert_vertex", "params": ["g", "v"], "called": 4 },
535+
{ "name": "insert_edge", "params": ["g", "start", "end"], "called": 5 },
536+
{ "name": "print_adj_mat", "params": ["g"], "called": 1 }
537+
],
538+
"steps": [
539+
{
540+
"line": 41,
541+
"description": "그래프 생성 및 초기화",
542+
"changes": [
543+
{ "variable": "g", "before": "empty", "after": "n=0, adj_mat 초기화됨" }
544+
],
545+
"dataStructure": {
546+
"type": "graph",
547+
"nodes": []
548+
}
549+
},
550+
{
551+
"line": 43,
552+
"description": "정점 0 삽입 (n=1)",
553+
"changes": [
554+
{ "variable": "g", "before": "n=0", "after": "n=1" }
555+
],
556+
"dataStructure": {
557+
"type": "graph",
558+
"nodes": ["0"]
559+
}
560+
},
561+
{
562+
"line": 43,
563+
"description": "정점 1 삽입 (n=2)",
564+
"changes": [
565+
{ "variable": "g", "before": "n=1", "after": "n=2" }
566+
],
567+
"dataStructure": {
568+
"type": "graph",
569+
"nodes": ["0", "1"]
570+
}
571+
},
572+
{
573+
"line": 43,
574+
"description": "정점 2 삽입 (n=3)",
575+
"changes": [
576+
{ "variable": "g", "before": "n=2", "after": "n=3" }
577+
],
578+
"dataStructure": {
579+
"type": "graph",
580+
"nodes": ["0", "1", "2"]
581+
}
582+
},
583+
{
584+
"line": 43,
585+
"description": "정점 3 삽입 (n=4)",
586+
"changes": [
587+
{ "variable": "g", "before": "n=3", "after": "n=4" }
588+
],
589+
"dataStructure": {
590+
"type": "graph",
591+
"nodes": ["0", "1", "2", "3"]
592+
}
593+
},
594+
{
595+
"line": 44,
596+
"description": "간선 (0,1) 추가",
597+
"changes": [],
598+
"dataStructure": {
599+
"type": "graph",
600+
"nodes": ["0", "1", "2", "3"],
601+
"edges": [["0", "1"]]
602+
}
603+
},
604+
{
605+
"line": 45,
606+
"description": "간선 (0,2) 추가",
607+
"changes": [],
608+
"dataStructure": {
609+
"type": "graph",
610+
"nodes": ["0", "1", "2", "3"],
611+
"edges": [["0", "1"], ["0", "2"]]
612+
}
613+
},
614+
{
615+
"line": 46,
616+
"description": "간선 (0,3) 추가",
617+
"changes": [],
618+
"dataStructure": {
619+
"type": "graph",
620+
"nodes": ["0", "1", "2", "3"],
621+
"edges": [["0", "1"], ["0", "2"], ["0", "3"]]
622+
}
623+
},
624+
{
625+
"line": 47,
626+
"description": "간선 (1,2) 추가",
627+
"changes": [],
628+
"dataStructure": {
629+
"type": "graph",
630+
"nodes": ["0", "1", "2", "3"],
631+
"edges": [["0", "1"], ["0", "2"], ["0", "3"], ["1", "2"]]
632+
}
633+
},
634+
{
635+
"line": 48,
636+
"description": "간선 (2,3) 추가",
637+
"changes": [],
638+
"dataStructure": {
639+
"type": "graph",
640+
"nodes": ["0", "1", "2", "3"],
641+
"edges": [["0", "1"], ["0", "2"], ["0", "3"], ["1", "2"], ["2", "3"]]
642+
}
643+
},
644+
{
645+
"line": 49,
646+
"description": "인접 행렬 출력",
647+
"changes": [],
648+
"dataStructure": {
649+
"type": "graph",
650+
"nodes": ["0", "1", "2", "3"],
651+
"adjacencyMatrix": [
652+
[0, 1, 1, 1],
653+
[1, 0, 1, 0],
654+
[1, 1, 0, 1],
655+
[1, 0, 1, 0]
656+
]
657+
}
658+
}
659+
]
660+
}, null, 2),
661+
type: "json"
662+
},
663+
{
664+
name: "binaryTree.json",
665+
code: JSON.stringify({
666+
"algorithm": "binary-tree",
667+
"lang": "c",
668+
"input": "",
669+
"variables": [
670+
{ "name": "root", "type": "Node*", "initialValue": "NULL", "currentValue": "0x01" },
671+
{ "name": "newNode", "type": "Node*", "initialValue": null, "currentValue": "0x05" }
672+
],
673+
"functions": [
674+
{ "name": "createNode", "params": ["data"] },
675+
{ "name": "insert", "params": ["root", "data"] },
676+
{ "name": "inorder", "params": ["root"] }
677+
],
678+
"steps": [
679+
{ "line": 29, "description": "main 시작, root 초기화", "changes": [{ "variable": "root", "before": "NULL", "after": "NULL" }] },
680+
{ "line": 30, "description": "insert(root, 50) 호출", "stack": [{ "function": "insert", "params": ["NULL", 50] }] },
681+
{ "line": 17, "description": "root == NULL, createNode(50) 호출", "stack": [{ "function": "createNode", "params": [50] }] },
682+
{ "line": 11, "description": "newNode 생성 및 초기화", "changes": [{ "variable": "newNode", "before": null, "after": "0x01" }], "dataStructure": { "type": "bst", "nodes": [{ "id": "0x01", "value": 50, "links": [] }] } },
683+
{ "line": 13, "description": "createNode 반환", "stack": [{ "function": "insert", "params": ["NULL", 50] }] },
684+
{ "line": 18, "description": "insert 반환, root=0x01", "changes": [{ "variable": "root", "before": "NULL", "after": "0x01" }] },
685+
{ "line": 31, "description": "insert(root, 30) 호출", "stack": [{ "function": "insert", "params": ["0x01", 30] }] },
686+
{ "line": 19, "description": "30 < 50, insert(root->left, 30) 재귀호출", "stack": [{ "function": "insert", "params": ["NULL", 30] }] },
687+
{ "line": 17, "description": "root==NULL, createNode(30) 호출", "stack": [{ "function": "createNode", "params": [30] }] },
688+
{ "line": 11, "description": "newNode 생성 및 초기화", "changes": [{ "variable": "newNode", "before": "0x01", "after": "0x02" }], "dataStructure": { "type": "bst", "nodes": [{ "id": "0x01", "value": 50, "links": ["0x02"] }, { "id": "0x02", "value": 30, "links": [] }] } },
689+
{ "line": 13, "description": "createNode 반환", "stack": [{ "function": "insert", "params": ["NULL", 30] }] },
690+
{ "line": 18, "description": "재귀 insert 반환, root->left=0x02", "stack": [{ "function": "insert", "params": ["0x01", 30] }] },
691+
{ "line": 22, "description": "insert 반환" },
692+
{ "line": 32, "description": "insert(root, 70) 호출", "stack": [{ "function": "insert", "params": ["0x01", 70] }] },
693+
{ "line": 20, "description": "70 > 50, insert(root->right, 70) 재귀호출", "stack": [{ "function": "insert", "params": ["NULL", 70] }] },
694+
{ "line": 17, "description": "root==NULL, createNode(70) 호출", "stack": [{ "function": "createNode", "params": [70] }] },
695+
{ "line": 11, "description": "newNode 생성 및 초기화", "changes": [{ "variable": "newNode", "before": "0x02", "after": "0x03" }], "dataStructure": { "type": "bst", "nodes": [{ "id": "0x01", "value": 50, "links": ["0x02", "0x03"] }, { "id": "0x02", "value": 30, "links": [] }, { "id": "0x03", "value": 70, "links": [] }] } },
696+
{ "line": 13, "description": "createNode 반환", "stack": [{ "function": "insert", "params": ["NULL", 70] }] },
697+
{ "line": 18, "description": "재귀 insert 반환, root->right=0x03", "stack": [{ "function": "insert", "params": ["0x01", 70] }] },
698+
{ "line": 22, "description": "insert 반환" },
699+
{ "line": 33, "description": "insert(root, 20) 호출", "stack": [{ "function": "insert", "params": ["0x01", 20] }] },
700+
{ "line": 19, "description": "20 < 50, insert(root->left, 20) 재귀호출", "stack": [{ "function": "insert", "params": ["0x02", 20] }] },
701+
{ "line": 19, "description": "20 < 30, insert(root->left, 20) 재귀호출", "stack": [{ "function": "insert", "params": ["NULL", 20] }] },
702+
{ "line": 17, "description": "root==NULL, createNode(20) 호출", "stack": [{ "function": "createNode", "params": [20] }] },
703+
{ "line": 11, "description": "newNode 생성 및 초기화", "changes": [{ "variable": "newNode", "before": "0x03", "after": "0x04" }], "dataStructure": { "type": "bst", "nodes": [{ "id": "0x01", "value": 50, "links": ["0x02", "0x03"] }, { "id": "0x02", "value": 30, "links": ["0x04"] }, { "id": "0x03", "value": 70, "links": [] }, { "id": "0x04", "value": 20, "links": [] }] } },
704+
{ "line": 13, "description": "createNode 반환" },
705+
{ "line": 18, "description": "재귀 insert 반환, root->left=0x04" },
706+
{ "line": 18, "description": "재귀 insert 반환, root->left=0x02" },
707+
{ "line": 22, "description": "insert 반환" },
708+
{ "line": 34, "description": "insert(root, 40) 호출", "stack": [{ "function": "insert", "params": ["0x01", 40] }] },
709+
{ "line": 19, "description": "40 < 50, insert(root->left, 40) 재귀호출", "stack": [{ "function": "insert", "params": ["0x02", 40] }] },
710+
{ "line": 20, "description": "40 > 30, insert(root->right, 40) 재귀호출", "stack": [{ "function": "insert", "params": ["NULL", 40] }] },
711+
{ "line": 17, "description": "root==NULL, createNode(40) 호출", "stack": [{ "function": "createNode", "params": [40] }] },
712+
{ "line": 11, "description": "newNode 생성 및 초기화", "changes": [{ "variable": "newNode", "before": "0x04", "after": "0x05" }], "dataStructure": { "type": "bst", "nodes": [{ "id": "0x01", "value": 50, "links": ["0x02", "0x03"] }, { "id": "0x02", "value": 30, "links": ["0x04", "0x05"] }, { "id": "0x03", "value": 70, "links": [] }, { "id": "0x04", "value": 20, "links": [] }, { "id": "0x05", "value": 40, "links": [] }] } },
713+
{ "line": 13, "description": "createNode 반환" },
714+
{ "line": 18, "description": "재귀 insert 반환, root->right=0x05" },
715+
{ "line": 18, "description": "재귀 insert 반환, root->left=0x02" },
716+
{ "line": 22, "description": "insert 반환" },
717+
{ "line": 36, "description": "printf(\"Inorder Traversal\")" },
718+
{ "line": 37, "description": "inorder(root) 호출", "stack": [{ "function": "inorder", "params": ["0x01"] }] },
719+
{ "line": 25, "description": "inorder(root->left) 호출", "stack": [{ "function": "inorder", "params": ["0x02"] }] },
720+
{ "line": 25, "description": "inorder(root->left) 호출", "stack": [{ "function": "inorder", "params": ["0x04"] }] },
721+
{ "line": 25, "description": "inorder(root->left=NULL), 반환" },
722+
{ "line": 27, "description": "출력: 20" },
723+
{ "line": 28, "description": "inorder(root->right=NULL), 반환" },
724+
{ "line": 27, "description": "출력: 30" },
725+
{ "line": 28, "description": "inorder(root->right) 호출", "stack": [{ "function": "inorder", "params": ["0x05"] }] },
726+
{ "line": 25, "description": "inorder(root->left=NULL), 반환" },
727+
{ "line": 27, "description": "출력: 40" },
728+
{ "line": 28, "description": "inorder(root->right=NULL), 반환" },
729+
{ "line": 27, "description": "출력: 50" },
730+
{ "line": 28, "description": "inorder(root->right) 호출", "stack": [{ "function": "inorder", "params": ["0x03"] }] },
731+
{ "line": 25, "description": "inorder(root->left=NULL), 반환" },
732+
{ "line": 27, "description": "출력: 70" },
733+
{ "line": 28, "description": "inorder(root->right=NULL), 반환" },
734+
{ "line": 39, "description": "main 종료" }
735+
]
736+
}, null, 2),
737+
type: "json"
522738
}
739+
523740
]);
524741

525742
// 🆕 파일 타입 감지 함수

0 commit comments

Comments
 (0)