-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
85 lines (77 loc) · 1.99 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"flag"
"fmt"
"log"
"os"
"projekt2/menu"
"time"
)
func main() {
logToFilePTR := flag.Bool("log-to-file", false, "Log to file")
flag.Parse()
if *logToFilePTR {
//save all logs to file
dateString := time.Now().Format("2006-01-02_15:04:05")
logFileName := dateString + ".log"
f, err := os.OpenFile(logFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
fmt.Println("Error opening file:", err)
} else {
defer func(f *os.File) {
err := f.Close()
if err != nil {
fmt.Println("Error closing file:", err)
}
}(f)
log.SetOutput(f)
}
}
menu.MainMenu()
//vertices := 100
//percentageConnected := 25
//
//graphDirected := myGraph.GenerateRandomGraph(vertices, percentageConnected, true, true)
//
//fmt.Println(graphDirected.GetEdgeCount())
//
//myGraph.Dijkstra(graphDirected, 0, 69)
////test, _ := myGraph.Dijkstra(graph, 0)
////fmt.Println(test)
//
//myGraph.BellmanFord(graphDirected, 0, 69)
////test2, _ := myGraph.BellmanFord(graph, 0)
////fmt.Println(test2)
//
//err1 := myGraph.SaveToFile(graphDirected, "graphDirectedThousandVertices.txt")
//if err1 != nil {
// fmt.Println("Error saving graph to file:", err1)
//} else {
// fmt.Println("Graph saved")
// log.Println("Graph saved")
//}
//
//graphUndirected := myGraph.GenerateRandomGraph(vertices, percentageConnected, false, true)
//
//fmt.Println(graphUndirected.GetEdgeCount())
//
//myGraph.Kruskal(graphUndirected, true)
//
//myGraph.Prim(graphUndirected, 0, true)
//
////mst1, time1 := myGraph.Kruskal(graph, true)
////fmt.Println(mst1.GetEdgeCount())
////fmt.Println("Time:", time1)
//////
////mst2, time1 := myGraph.Prim(graph, 0, true)
////fmt.Println(mst2.GetEdgeCount())
////fmt.Println("Time:", time1)
//
//err2 := myGraph.SaveToFile(graphUndirected, "graphDirectedThousandVertices.txt")
//if err2 != nil {
// fmt.Println("Error saving graph to file:", err2)
//} else {
// fmt.Println("Graph saved")
// log.Println("Graph saved")
//}
}