示例#1
0
def twoDictsDistCompare(dictOfGraphs1, dictOfGraphs2):
    """Compare two dicts of graphs."""
    coordDict1 = getCentrCoord(dictOfGraphs1)
    coordDict2 = getCentrCoord(dictOfGraphs2)
    # mean1 = meanPoint(coordDict1)
    mean2 = meanPoint(coordDict2)
    distanceDict1 = dict()
    for point in coordDict1.values():
        sumofsquares = (point[0] - mean2[0])**2 + (point[1] - mean2[1])**2
        distance = float(format(sumofsquares**(0.5), '.2f'))
        distanceDict1[point] = distance
    maxdistance = min(list(distanceDict1.values()))
    offPoint = getKeyByValue(distanceDict1, maxdistance)
    offPiece1 = getKeyByValue(coordDict1, offPoint)

    distanceDict2 = dict()
    for point in coordDict2.values():
        sumofsquares = (point[0] - mean2[0])**2 + (point[1] - mean2[1])**2
        distance = float(format(sumofsquares**(0.5), '.2f'))
        distanceDict2[point] = distance
    maxdistance = min(list(distanceDict2.values()))
    offPoint = getKeyByValue(distanceDict2, maxdistance)
    offPiece2 = getKeyByValue(coordDict2, offPoint)

    return offPiece1, offPiece2
示例#2
0
def SpectralGraphCompare(dictOfGraphs):
    """Compare the spectrum of a dict of graphs."""
    graphComparison = ComparingGraphs(dictOfGraphs)
    minimum = min(list(graphComparison.values()))
    maximum = max(list(graphComparison.values()))
    print(getKeyByValue(graphComparison, minimum), minimum)
    print(getKeyByValue(graphComparison, maximum), maximum)
    return graphComparison
def graphSimilarity(graphDict):
    """Compute the eigenvalue similarity of graphs."""
    similarityDict = dict()
    for g1 in graphDict.values():
        for g2 in graphDict.values():
            if g1 != g2:
                key1 = getKeyByValue(graphDict, g1)
                key2 = getKeyByValue(graphDict, g2)
                if (key2, key1) not in similarityDict.keys():
                    similarityDict[(key1,
                                    key2)] = CompareGraphsSpectrum(g1, g2)
    return sorted(similarityDict.items(), key=lambda kv: kv[1])
示例#4
0
def getInPoint(coordDict):
    """Get the points that are closer to center of distribution."""
    distanceDict = dict()
    mean = meanPoint(coordDict)
    for point in coordDict.values():
        sumofsquares = (point[0] - mean[0])**2 + (point[1] - mean[1])**2
        distance = float(format(sumofsquares**(0.5), '.2f'))
        distanceDict[point] = distance
    maxdistance = min(list(distanceDict.values()))
    offPoint = getKeyByValue(distanceDict, maxdistance)
    offPiece = getKeyByValue(coordDict, offPoint)
    return offPiece
示例#5
0
def SortPiecesByDistances(dictOfGraphs):
    """Make a sortet list of pieces based on the distance from the mean."""
    coordDict = getCentrCoord(dictOfGraphs)
    distanceDict = dict()
    mean = meanPoint(coordDict)
    for point in coordDict.values():
        sumofsquares = (point[0] - mean[0])**2 + (point[1] - mean[1])**2
        distance = float(format(sumofsquares**(0.5), '.2f'))
        distanceDict[point] = distance
    distance = sorted(distanceDict.values())
    print(distance)
    for dist in distance:
        point = getKeyByValue(distanceDict, dist)
        piece = getKeyByValue(coordDict, point)
        print(piece)
def TonnetzToString(Tonnetz):
    """TonnetzToString: List -> String."""
    TonnetzString = getKeyByValue(dictOfTonnetze, Tonnetz)
    return TonnetzString
示例#7
0
def addConnectivity(TonnetzList, connectivity):
    for el in TonnetzList:
        el[3] = connectivity[getKeyByValue(dictOfTonnetze, el[0])]
    return TonnetzList