<jupyter_start><jupyter_text>Adjacency Matrix<jupyter_code>import numpy as np<jupyter_output><empty_output><jupyter_text>Adjacency Matrix - determine value in cell, from an adjacent cellMagic Characteristics - center cell value, center cell coordinates, origin coordinates, polynomial base, Magic Cube - construction and "dictionary" Structure of Adjacency Matrix<jupyter_code>import numpy as np

class AdjacencyMatrix:
    """Given a cell within a magic square, an adjacency matrix calculates the value of an adjacent cell

    an adjacency matrix can also be used to calculate the value of a non-adjacent cell via 'multiplication'
    """

    def __init__(self, dimensions):
        self.dimensions = dimensions
        self.matrix = np.ones((dimensions, dimensions), dtype=np.int64)
        self.__prepare_matrix()

    def __prepare_matrix(self):
        for i in range(self.dimensions):
            for j in range(self.dimensions):
                if ((i + j) > (self.dimensions - 2)):
                    self.matrix[i,j] = 1
                else:
                    self.matrix[i,j] = -1
am = AdjacencyMatrix(7).matrix
amm = np.asmatrix(am)
amm
ammt = amm.T
ammt
ammt.I<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08609271523178808, 'fraction_numerical': 0.004966887417218543, 'mean_word_length': 3.227272727272727, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '605516', 'license': 'MIT', 'n_tokens_mistral': 370, 'n_tokens_neox': 346, 'n_words': 112, 'path': 'numpy-data-science-essential-training/Ex_Files_NumPy_Data_EssT/Exercise Files/Ch 7/07_04/Finish/.ipynb_checkpoints/Adjacency Matrix-checkpoint.ipynb', 'repo_name': 'saint1729/in-learning', 'size': '1208'}