59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
/*
|
|
Copyright (C) 2024 filifa
|
|
|
|
This program is free software: you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
Foundation, either version 3 of the License, or (at your option) any later
|
|
version.
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"gonum.org/v1/gonum/graph/encoding/dot"
|
|
)
|
|
|
|
func main() {
|
|
f := flag.String("f", "", "graphviz file")
|
|
flag.Parse()
|
|
|
|
if *f == "" {
|
|
log.Fatal("-f is required")
|
|
}
|
|
|
|
contents, err := os.ReadFile(*f)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
g := newProjectNetwork()
|
|
err = dot.Unmarshal(contents, g)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
err = g.calculateTimes()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
data, err := dot.Marshal(g, "", "", "\t")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
fmt.Println(string(data))
|
|
}
|