Skip to content

Commit

Permalink
analyzer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arorasoham9 committed May 17, 2024
1 parent 9871212 commit 8246425
Showing 1 changed file with 41 additions and 17 deletions.
58 changes: 41 additions & 17 deletions pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -881,41 +881,65 @@ func CompareTwoPaths(analysisListOne, analysisListTwo []*Node) ([][]string, int,
}

func CompareAllPaths(listOne, listTwo [][]*Node) ([]DiffedPath, error) {
if len(listTwo) != len(listOne) {
//do something?
}

// var small, big [][]*Node
// if len(listOne) > len(listTwo) {
// small= listTwo
// big = listOne
// } else if len(listTwo) > len(listOne) {
// small= listOne
// big = listTwo
// } else {
// small= listTwo
// big = listOne
// }

var small, big [][]*Node
if len(listOne) > len(listTwo) {
small= listTwo
big = listOne
} else if len(listTwo) > len(listOne) {
small= listOne
big = listTwo
} else {
small= listTwo
big = listOne
}

var results []DiffedPath
for _, pathOne := range listOne {
used := make(map[int]bool)

for _, pathOne := range small {

var diff DiffedPath
diff.PathOne = pathOne
min := math.MaxInt64
for _, pathTwo := range listTwo {
var index int

for i, pathTwo := range big {
_, ok := used[i]
if ok{
continue
}

diffs, diffNum, err := CompareTwoPaths(pathOne, pathTwo)

if err != nil {
return results, fmt.Errorf(err.Error())
}

// if diffNum > //some number {
// continue
// }


if diffNum < min {
diff.PathTwo = pathTwo
min = diffNum
diff.Diffs = diffs
index = i
}
}
used[index] = true
results = append(results, diff)
}

for i, val := range big {
_, ok := used[i]
if !ok {
results = append(results, DiffedPath{PathOne: val, })
}
}


return results, nil
}

Expand Down

0 comments on commit 8246425

Please sign in to comment.