コード例 #1
0
ファイル: MtPivot.go プロジェクト: JSoddy/goplay
func loadDictionary() dictionary {
	dict := dictionary{}
	//read file lines
	input := file.FileLines(fileName)
	// break out first line, load its values into size
	dict.size = intSeparate(input[0])
	input = input[1:]
	// break out second line, load it into basic
	dict.basic = intSeparate(input[0])
	input = input[1:]
	// break out third line, load it into nonBasic
	dict.nonBasic = intSeparate(input[0])
	input = input[1:]
	// break out fourth line, load it into coeff
	dict.coeff = floatSeparate(input[0])
	input = input[1:]
	// for next size[0] lines, load into matrix
	dict.matrix = make([][]float64, dict.size[0])
	for i := 0; i < dict.size[0]; i++ {
		dict.matrix[i] = floatSeparate(input[0])
		input = input[1:]
	}
	// load final line into objective
	dict.objective = floatSeparate(input[0])
	return dict
}
コード例 #2
0
ファイル: scheduling.go プロジェクト: JSoddy/goplay
func loadJobs() *jobList {
	a := file.FileLines(fileName)[1:]
	jobSlice := make(jobList, 10000)

	for i, v := range a {
		jobSlice[i] = addJob(v)
	}
	return &jobSlice
}
コード例 #3
0
ファイル: knapsack.go プロジェクト: JSoddy/goplay
func loadArray() ([]item, int) {
	fileLines := file.FileLines(fileToken)
	paramLine := strings.Split(fileLines[0], "\n")
	fileLines = fileLines[1:]
	paramLine = strings.Split(paramLine[0], " ")
	knapSize, _ := strconv.Atoi(paramLine[0])

	itemList := readKnap(fileLines)
	return itemList, knapSize
}
コード例 #4
0
ファイル: dijkstra.go プロジェクト: JSoddy/goplay
// () -> Graph
// Outputs a graph containing the contents of file "fileToken"
func loadGraph() Graph {

	a := file.FileLines(fileToken)
	g := make(Graph, 0)
	for i := 0; i < len(a); i++ {
		g = append(g, new(Node))
	}
	for _, l := range a {
		addNode(g, l)
	}
	return g
}
コード例 #5
0
ファイル: bigclust.go プロジェクト: JSoddy/goplay
func readNodes() [][]bool {
	lines := file.FileLines(fileToken)
	params := strings.Split(strings.Split(lines[0], "\n")[0], " ")
	lines = lines[1:]
	count, _ := strconv.Atoi(params[0])
	size, _ := strconv.Atoi(params[1])
	graph := make([][]bool, count)
	for i := 0; i < count; i++ {
		graph[i] = newNode(lines[i], size)
	}
	return graph
}
コード例 #6
0
ファイル: Clustering.go プロジェクト: JSoddy/goplay
func loadGraph() graph {
	lines := file.FileLines(fileToken)
	graphSize, _ := strconv.Atoi((strings.Split(lines[0], "\n")[0]))
	lines = lines[1:]
	vertices := make([]vertex, graphSize)
	for i, _ := range vertices {
		vertices[i] = vertex{i + 1, 0}
	}
	edges := make(edgeList, len(lines))
	for i, v := range lines {
		edges[i] = newEdge(v)
	}
	return graph{edges: edges, vertices: vertices, kvalue: len(vertices)}
}
コード例 #7
0
ファイル: prim.go プロジェクト: JSoddy/goplay
func loadGraph() *Graph {
	fileStrings := file.FileLines(fileName)

	countStrings := strings.Split(strings.TrimSuffix(fileStrings[0], "\n"), " ")
	nodeCount, _ := strconv.Atoi(countStrings[0])
	graphNodes := make(Graph, nodeCount)

	fileStrings = fileStrings[1:]
	initializeNodes(&graphNodes)

	for _, v := range fileStrings {
		addEdge(graphNodes, v)
	}

	return &graphNodes
}
コード例 #8
0
ファイル: allpoints.go プロジェクト: JSoddy/goplay
// () -> Graph
// Outputs a graph containing the contents of file "fileToken"
func loadGraph() graph.Graph {
	fmt.Println("Opening file...")
	rawLines := file.FileLines(fileToken)
	fmt.Println("Creating structures...")
	values := strings.Split(rawLines[0], "\n")
	values = strings.Split(values[0], " ")
	vCount, _ := strconv.Atoi(values[0])
	eCount, _ := strconv.Atoi(values[1])
	rawLines = rawLines[1:]
	vertices := make([]*graph.Node, vCount)
	edges := make([]graph.Edge, eCount)
	for i := 0; i < len(vertices); i++ {
		vertices[i] = &graph.Node{Name: i + 1}
	}
	fmt.Println("Entering data...")
	for i, v := range rawLines {
		edges[i] = addEdge(vertices, v)
	}
	return graph.Graph{Vertices: vertices, Edges: edges}
}