File size: 56,125 Bytes
edc4c5e
1
{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"EvTuwbs9r4aw","executionInfo":{"status":"ok","timestamp":1709307950772,"user_tz":300,"elapsed":18530,"user":{"displayName":"清水幸","userId":"09251711040897455590"}},"outputId":"e4c04ebf-fb5a-4990-da77-a450598b3df7"},"outputs":[{"output_type":"stream","name":"stdout","text":["Mounted at /content/drive\n","/content/drive/MyDrive/Colab_Notebooks/Marvel_network\n"]}],"source":["import numpy as np\n","import pandas as pd\n","import networkx as nx\n","import matplotlib.pyplot as plt\n","from tqdm import trange\n","from google.colab import drive\n","drive.mount('/content/drive')\n","%cd /content/drive/MyDrive/Colab_Notebooks/Marvel_network"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"QHxuWhh8r4ay","executionInfo":{"status":"ok","timestamp":1709308038937,"user_tz":300,"elapsed":1658,"user":{"displayName":"清水幸","userId":"09251711040897455590"}},"outputId":"ff562e1f-3640-49d7-bcf1-9f69c9f127ad"},"outputs":[{"output_type":"stream","name":"stdout","text":["96104\n","574467\n"]}],"source":["# Read datasets\n","elements=pd.read_csv('source_data/nodes.csv')\n","hero=elements[elements['type']=='hero']['node']\n","comic=elements[elements['type']=='comic']['node']\n","hero_comic=pd.read_csv('source_data/edges.csv')\n","print(len(hero_comic))\n","hero_hero=pd.read_csv('source_data/hero-network.csv')\n","print(len(hero_hero))"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"KFLbMoter4ay","executionInfo":{"status":"ok","timestamp":1709308042509,"user_tz":300,"elapsed":306,"user":{"displayName":"清水幸","userId":"09251711040897455590"}},"outputId":"f7898146-fca2-4056-b846-1151f5d34583"},"outputs":[{"output_type":"stream","name":"stdout","text":["82593\n","424270\n"]}],"source":["# Create hero and comic lists\n","hero=list((set(hero_hero['hero1']).union(\n","    set(hero_hero['hero2']))).intersection(\n","        set(hero_comic['hero'])).intersection(\n","            set(hero)\n","        ))\n","\n","comic=list(set(hero_comic['comic']).intersection(set(comic)))\n","\n","# Delete edges containing unknown hero/comic\n","hero_comic=hero_comic[hero_comic['comic'].isin(comic)]\n","hero_comic=hero_comic[hero_comic['hero'].isin(hero)]\n","print(len(hero_comic))\n","\n","hero_hero=hero_hero[hero_hero['hero1'].isin(hero)]\n","hero_hero=hero_hero[hero_hero['hero2'].isin(hero)]\n","print(len(hero_hero))"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"_BrGgTMMr4az","executionInfo":{"status":"ok","timestamp":1709308185730,"user_tz":300,"elapsed":140840,"user":{"displayName":"清水幸","userId":"09251711040897455590"}},"outputId":"8b2f9eea-5144-48e7-b33c-f17e8525610d"},"outputs":[{"output_type":"stream","name":"stderr","text":["100%|██████████| 6282/6282 [02:20<00:00, 44.62it/s]\n"]}],"source":["# Determine in which comics the hero pairs meet\n","hero_hero_comic=pd.DataFrame(columns=['hero1','hero2','comic'])\n","for i in trange(len(hero)):\n","    hero1=hero[i]\n","    pair1=hero_comic[hero_comic['hero']==hero1]\n","    hero_comic=hero_comic[hero_comic['hero']!=hero1]\n","    pair2=hero_comic[hero_comic['comic'].isin(pair1['comic'])]\n","    pair2.columns=['hero2', 'comic']\n","    pair2.insert(0,'hero1',hero1,True)\n","    hero_hero_comic=pd.concat([hero_hero_comic,pair2])"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"gBvjnLn0r4az","executionInfo":{"status":"ok","timestamp":1709308287123,"user_tz":300,"elapsed":101398,"user":{"displayName":"清水幸","userId":"09251711040897455590"}},"outputId":"c6757189-dd0f-4f67-9e92-709dcd87be0b"},"outputs":[{"output_type":"stream","name":"stderr","text":["100%|██████████| 142289/142289 [00:25<00:00, 5543.05it/s]\n","100%|██████████| 183645/183645 [01:15<00:00, 2442.47it/s]\n"]}],"source":["def flatten_list(matrix):\n","    flat_list = []\n","    for row in matrix:\n","        flat_list += row\n","    return flat_list\n","\n","# List unique pairs\n","existing_pairs=hero_hero_comic[['hero1','hero2']].drop_duplicates()\n","existing_pairs=[[(existing_pairs.iloc[i]['hero1'],existing_pairs.iloc[i]['hero2']),\n","                 (existing_pairs.iloc[i]['hero2'],existing_pairs.iloc[i]['hero1']) ]\n","                 for i in trange(len(existing_pairs))]\n","existing_pairs=flatten_list(existing_pairs)\n","\n","hero_hero=hero_hero.groupby(['hero1','hero2']).size().reset_index(name='counts')\n","adding_pairs=hero_hero.drop_duplicates()\n","adding_pairs=[(adding_pairs.iloc[i]['hero1'],adding_pairs.iloc[i]['hero2'])\n","                 for i in trange(len(adding_pairs))\n","                 if adding_pairs.iloc[i]['hero1']!=adding_pairs.iloc[i]['hero2']]\n"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":424},"id":"A07g1IEzr4az","executionInfo":{"status":"ok","timestamp":1709308287288,"user_tz":300,"elapsed":311,"user":{"displayName":"清水幸","userId":"09251711040897455590"}},"outputId":"b0a8969e-0f00-4f16-dbb8-590e5b77795c"},"outputs":[{"output_type":"execute_result","data":{"text/plain":["                      hero1                 hero2    comic\n","0                     ZAKKA          BROTHER TODE      E 1\n","1                     ZAKKA    DAMIAN, DR. DANIEL      E 1\n","2                     ZAKKA         DAMIAN, MARGO      E 1\n","3                     ZAKKA  IKARIS/IKE HARRIS [E      E 1\n","4                     ZAKKA      KARKAS [DEVIANT]      E 1\n","...                     ...                   ...      ...\n","426553          BLAQUESMITH  PSYLOCKE/ELISABETH B    C2 31\n","426554          BLAQUESMITH  PSYLOCKE/ELISABETH B  X:PRIME\n","426555  PALADIN/PAUL DENNIS       FROST, ADRIENNE  GENX 52\n","426556  PALADIN/PAUL DENNIS       FROST, ADRIENNE  GENX 53\n","426557  PALADIN/PAUL DENNIS       FROST, ADRIENNE  GENX 54\n","\n","[426558 rows x 3 columns]"],"text/html":["\n","  <div id=\"df-b4b01ab8-6fb7-4024-9125-66d0a20d25a2\" class=\"colab-df-container\">\n","    <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>hero1</th>\n","      <th>hero2</th>\n","      <th>comic</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>ZAKKA</td>\n","      <td>BROTHER TODE</td>\n","      <td>E 1</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>ZAKKA</td>\n","      <td>DAMIAN, DR. DANIEL</td>\n","      <td>E 1</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>ZAKKA</td>\n","      <td>DAMIAN, MARGO</td>\n","      <td>E 1</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>ZAKKA</td>\n","      <td>IKARIS/IKE HARRIS [E</td>\n","      <td>E 1</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>ZAKKA</td>\n","      <td>KARKAS [DEVIANT]</td>\n","      <td>E 1</td>\n","    </tr>\n","    <tr>\n","      <th>...</th>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","    </tr>\n","    <tr>\n","      <th>426553</th>\n","      <td>BLAQUESMITH</td>\n","      <td>PSYLOCKE/ELISABETH B</td>\n","      <td>C2 31</td>\n","    </tr>\n","    <tr>\n","      <th>426554</th>\n","      <td>BLAQUESMITH</td>\n","      <td>PSYLOCKE/ELISABETH B</td>\n","      <td>X:PRIME</td>\n","    </tr>\n","    <tr>\n","      <th>426555</th>\n","      <td>PALADIN/PAUL DENNIS</td>\n","      <td>FROST, ADRIENNE</td>\n","      <td>GENX 52</td>\n","    </tr>\n","    <tr>\n","      <th>426556</th>\n","      <td>PALADIN/PAUL DENNIS</td>\n","      <td>FROST, ADRIENNE</td>\n","      <td>GENX 53</td>\n","    </tr>\n","    <tr>\n","      <th>426557</th>\n","      <td>PALADIN/PAUL DENNIS</td>\n","      <td>FROST, ADRIENNE</td>\n","      <td>GENX 54</td>\n","    </tr>\n","  </tbody>\n","</table>\n","<p>426558 rows × 3 columns</p>\n","</div>\n","    <div class=\"colab-df-buttons\">\n","\n","  <div class=\"colab-df-container\">\n","    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-b4b01ab8-6fb7-4024-9125-66d0a20d25a2')\"\n","            title=\"Convert this dataframe to an interactive table.\"\n","            style=\"display:none;\">\n","\n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n","    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n","  </svg>\n","    </button>\n","\n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    .colab-df-buttons div {\n","      margin-bottom: 4px;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","    <script>\n","      const buttonEl =\n","        document.querySelector('#df-b4b01ab8-6fb7-4024-9125-66d0a20d25a2 button.colab-df-convert');\n","      buttonEl.style.display =\n","        google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","      async function convertToInteractive(key) {\n","        const element = document.querySelector('#df-b4b01ab8-6fb7-4024-9125-66d0a20d25a2');\n","        const dataTable =\n","          await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                    [key], {});\n","        if (!dataTable) return;\n","\n","        const docLinkHtml = 'Like what you see? Visit the ' +\n","          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","          + ' to learn more about interactive tables.';\n","        element.innerHTML = '';\n","        dataTable['output_type'] = 'display_data';\n","        await google.colab.output.renderOutput(dataTable, element);\n","        const docLink = document.createElement('div');\n","        docLink.innerHTML = docLinkHtml;\n","        element.appendChild(docLink);\n","      }\n","    </script>\n","  </div>\n","\n","\n","<div id=\"df-3c75e577-f77b-4e96-9d19-bb2233050c20\">\n","  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-3c75e577-f77b-4e96-9d19-bb2233050c20')\"\n","            title=\"Suggest charts\"\n","            style=\"display:none;\">\n","\n","<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","     width=\"24px\">\n","    <g>\n","        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n","    </g>\n","</svg>\n","  </button>\n","\n","<style>\n","  .colab-df-quickchart {\n","      --bg-color: #E8F0FE;\n","      --fill-color: #1967D2;\n","      --hover-bg-color: #E2EBFA;\n","      --hover-fill-color: #174EA6;\n","      --disabled-fill-color: #AAA;\n","      --disabled-bg-color: #DDD;\n","  }\n","\n","  [theme=dark] .colab-df-quickchart {\n","      --bg-color: #3B4455;\n","      --fill-color: #D2E3FC;\n","      --hover-bg-color: #434B5C;\n","      --hover-fill-color: #FFFFFF;\n","      --disabled-bg-color: #3B4455;\n","      --disabled-fill-color: #666;\n","  }\n","\n","  .colab-df-quickchart {\n","    background-color: var(--bg-color);\n","    border: none;\n","    border-radius: 50%;\n","    cursor: pointer;\n","    display: none;\n","    fill: var(--fill-color);\n","    height: 32px;\n","    padding: 0;\n","    width: 32px;\n","  }\n","\n","  .colab-df-quickchart:hover {\n","    background-color: var(--hover-bg-color);\n","    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n","    fill: var(--button-hover-fill-color);\n","  }\n","\n","  .colab-df-quickchart-complete:disabled,\n","  .colab-df-quickchart-complete:disabled:hover {\n","    background-color: var(--disabled-bg-color);\n","    fill: var(--disabled-fill-color);\n","    box-shadow: none;\n","  }\n","\n","  .colab-df-spinner {\n","    border: 2px solid var(--fill-color);\n","    border-color: transparent;\n","    border-bottom-color: var(--fill-color);\n","    animation:\n","      spin 1s steps(1) infinite;\n","  }\n","\n","  @keyframes spin {\n","    0% {\n","      border-color: transparent;\n","      border-bottom-color: var(--fill-color);\n","      border-left-color: var(--fill-color);\n","    }\n","    20% {\n","      border-color: transparent;\n","      border-left-color: var(--fill-color);\n","      border-top-color: var(--fill-color);\n","    }\n","    30% {\n","      border-color: transparent;\n","      border-left-color: var(--fill-color);\n","      border-top-color: var(--fill-color);\n","      border-right-color: var(--fill-color);\n","    }\n","    40% {\n","      border-color: transparent;\n","      border-right-color: var(--fill-color);\n","      border-top-color: var(--fill-color);\n","    }\n","    60% {\n","      border-color: transparent;\n","      border-right-color: var(--fill-color);\n","    }\n","    80% {\n","      border-color: transparent;\n","      border-right-color: var(--fill-color);\n","      border-bottom-color: var(--fill-color);\n","    }\n","    90% {\n","      border-color: transparent;\n","      border-bottom-color: var(--fill-color);\n","    }\n","  }\n","</style>\n","\n","  <script>\n","    async function quickchart(key) {\n","      const quickchartButtonEl =\n","        document.querySelector('#' + key + ' button');\n","      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n","      quickchartButtonEl.classList.add('colab-df-spinner');\n","      try {\n","        const charts = await google.colab.kernel.invokeFunction(\n","            'suggestCharts', [key], {});\n","      } catch (error) {\n","        console.error('Error during call to suggestCharts:', error);\n","      }\n","      quickchartButtonEl.classList.remove('colab-df-spinner');\n","      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n","    }\n","    (() => {\n","      let quickchartButtonEl =\n","        document.querySelector('#df-3c75e577-f77b-4e96-9d19-bb2233050c20 button');\n","      quickchartButtonEl.style.display =\n","        google.colab.kernel.accessAllowed ? 'block' : 'none';\n","    })();\n","  </script>\n","</div>\n","\n","  <div id=\"id_ce5306d2-47ae-4a94-8d95-b6725daf84e4\">\n","    <style>\n","      .colab-df-generate {\n","        background-color: #E8F0FE;\n","        border: none;\n","        border-radius: 50%;\n","        cursor: pointer;\n","        display: none;\n","        fill: #1967D2;\n","        height: 32px;\n","        padding: 0 0 0 0;\n","        width: 32px;\n","      }\n","\n","      .colab-df-generate:hover {\n","        background-color: #E2EBFA;\n","        box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","        fill: #174EA6;\n","      }\n","\n","      [theme=dark] .colab-df-generate {\n","        background-color: #3B4455;\n","        fill: #D2E3FC;\n","      }\n","\n","      [theme=dark] .colab-df-generate:hover {\n","        background-color: #434B5C;\n","        box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","        filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","        fill: #FFFFFF;\n","      }\n","    </style>\n","    <button class=\"colab-df-generate\" onclick=\"generateWithVariable('hero_hero_comic')\"\n","            title=\"Generate code using this dataframe.\"\n","            style=\"display:none;\">\n","\n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/>\n","  </svg>\n","    </button>\n","    <script>\n","      (() => {\n","      const buttonEl =\n","        document.querySelector('#id_ce5306d2-47ae-4a94-8d95-b6725daf84e4 button.colab-df-generate');\n","      buttonEl.style.display =\n","        google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","      buttonEl.onclick = () => {\n","        google.colab.notebook.generateWithVariable('hero_hero_comic');\n","      }\n","      })();\n","    </script>\n","  </div>\n","\n","    </div>\n","  </div>\n"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"dataframe","variable_name":"hero_hero_comic"}},"metadata":{},"execution_count":8}],"source":["# Create a dataframe, containing hero pairs and the comics with them\n","unknown_pairs=list(set(adding_pairs)-set(existing_pairs))\n","for pair in unknown_pairs:\n","    hero1=pair[0]\n","    hero2=pair[1]\n","    if len(hero_hero[(hero_hero['hero1']==pair[0]) & (hero_hero['hero2']==pair[1])])==1:\n","        count=hero_hero[(hero_hero['hero1']==pair[0]) & (hero_hero['hero2']==pair[1])]['counts'].iloc[0]\n","        for i in range(int(count)):\n","            hero_hero_comic.loc[len(hero_hero_comic)]=[hero1,hero2,'UNKNOWN']\n","    else:\n","        continue\n","\n","hero_hero_comic=hero_hero_comic.reset_index(drop=True)\n","hero_hero_comic"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":424},"id":"uCmZdjgMr4az","executionInfo":{"status":"ok","timestamp":1709308287568,"user_tz":300,"elapsed":285,"user":{"displayName":"清水幸","userId":"09251711040897455590"}},"outputId":"4e747d00-5111-437c-9386-929a973402e7"},"outputs":[{"output_type":"execute_result","data":{"text/plain":["                       hero1                 hero2  counts\n","0       3-D MAN/CHARLES CHAN  AJAK/TECUMOTZIN [ETE       1\n","1       3-D MAN/CHARLES CHAN  ANGEL/WARREN KENNETH       1\n","2       3-D MAN/CHARLES CHAN  ANT-MAN II/SCOTT HAR       1\n","3       3-D MAN/CHARLES CHAN  ANT-MAN/DR. HENRY J.       2\n","4       3-D MAN/CHARLES CHAN  ARABIAN KNIGHT/ABDUL       1\n","...                      ...                   ...     ...\n","142284                 ZZZAX      RODRIGUEZ, DEBRA       1\n","142285                 ZZZAX  SUMMERS, NATHAN CHRI       1\n","142286                 ZZZAX         TALBOT, GLENN       1\n","142287                 ZZZAX    TIGRA/GREER NELSON       1\n","142288                 ZZZAX  WONDER MAN/SIMON WIL       1\n","\n","[142289 rows x 3 columns]"],"text/html":["\n","  <div id=\"df-e9f051a8-cd6a-4272-8ea3-175415630edc\" class=\"colab-df-container\">\n","    <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>hero1</th>\n","      <th>hero2</th>\n","      <th>counts</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>3-D MAN/CHARLES CHAN</td>\n","      <td>AJAK/TECUMOTZIN [ETE</td>\n","      <td>1</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>3-D MAN/CHARLES CHAN</td>\n","      <td>ANGEL/WARREN KENNETH</td>\n","      <td>1</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>3-D MAN/CHARLES CHAN</td>\n","      <td>ANT-MAN II/SCOTT HAR</td>\n","      <td>1</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>3-D MAN/CHARLES CHAN</td>\n","      <td>ANT-MAN/DR. HENRY J.</td>\n","      <td>2</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>3-D MAN/CHARLES CHAN</td>\n","      <td>ARABIAN KNIGHT/ABDUL</td>\n","      <td>1</td>\n","    </tr>\n","    <tr>\n","      <th>...</th>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","    </tr>\n","    <tr>\n","      <th>142284</th>\n","      <td>ZZZAX</td>\n","      <td>RODRIGUEZ, DEBRA</td>\n","      <td>1</td>\n","    </tr>\n","    <tr>\n","      <th>142285</th>\n","      <td>ZZZAX</td>\n","      <td>SUMMERS, NATHAN CHRI</td>\n","      <td>1</td>\n","    </tr>\n","    <tr>\n","      <th>142286</th>\n","      <td>ZZZAX</td>\n","      <td>TALBOT, GLENN</td>\n","      <td>1</td>\n","    </tr>\n","    <tr>\n","      <th>142287</th>\n","      <td>ZZZAX</td>\n","      <td>TIGRA/GREER NELSON</td>\n","      <td>1</td>\n","    </tr>\n","    <tr>\n","      <th>142288</th>\n","      <td>ZZZAX</td>\n","      <td>WONDER MAN/SIMON WIL</td>\n","      <td>1</td>\n","    </tr>\n","  </tbody>\n","</table>\n","<p>142289 rows × 3 columns</p>\n","</div>\n","    <div class=\"colab-df-buttons\">\n","\n","  <div class=\"colab-df-container\">\n","    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-e9f051a8-cd6a-4272-8ea3-175415630edc')\"\n","            title=\"Convert this dataframe to an interactive table.\"\n","            style=\"display:none;\">\n","\n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n","    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n","  </svg>\n","    </button>\n","\n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    .colab-df-buttons div {\n","      margin-bottom: 4px;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","    <script>\n","      const buttonEl =\n","        document.querySelector('#df-e9f051a8-cd6a-4272-8ea3-175415630edc button.colab-df-convert');\n","      buttonEl.style.display =\n","        google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","      async function convertToInteractive(key) {\n","        const element = document.querySelector('#df-e9f051a8-cd6a-4272-8ea3-175415630edc');\n","        const dataTable =\n","          await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                    [key], {});\n","        if (!dataTable) return;\n","\n","        const docLinkHtml = 'Like what you see? Visit the ' +\n","          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","          + ' to learn more about interactive tables.';\n","        element.innerHTML = '';\n","        dataTable['output_type'] = 'display_data';\n","        await google.colab.output.renderOutput(dataTable, element);\n","        const docLink = document.createElement('div');\n","        docLink.innerHTML = docLinkHtml;\n","        element.appendChild(docLink);\n","      }\n","    </script>\n","  </div>\n","\n","\n","<div id=\"df-1c9ff2b7-5185-44b3-bf0a-fc98b137fbe8\">\n","  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-1c9ff2b7-5185-44b3-bf0a-fc98b137fbe8')\"\n","            title=\"Suggest charts\"\n","            style=\"display:none;\">\n","\n","<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","     width=\"24px\">\n","    <g>\n","        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n","    </g>\n","</svg>\n","  </button>\n","\n","<style>\n","  .colab-df-quickchart {\n","      --bg-color: #E8F0FE;\n","      --fill-color: #1967D2;\n","      --hover-bg-color: #E2EBFA;\n","      --hover-fill-color: #174EA6;\n","      --disabled-fill-color: #AAA;\n","      --disabled-bg-color: #DDD;\n","  }\n","\n","  [theme=dark] .colab-df-quickchart {\n","      --bg-color: #3B4455;\n","      --fill-color: #D2E3FC;\n","      --hover-bg-color: #434B5C;\n","      --hover-fill-color: #FFFFFF;\n","      --disabled-bg-color: #3B4455;\n","      --disabled-fill-color: #666;\n","  }\n","\n","  .colab-df-quickchart {\n","    background-color: var(--bg-color);\n","    border: none;\n","    border-radius: 50%;\n","    cursor: pointer;\n","    display: none;\n","    fill: var(--fill-color);\n","    height: 32px;\n","    padding: 0;\n","    width: 32px;\n","  }\n","\n","  .colab-df-quickchart:hover {\n","    background-color: var(--hover-bg-color);\n","    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n","    fill: var(--button-hover-fill-color);\n","  }\n","\n","  .colab-df-quickchart-complete:disabled,\n","  .colab-df-quickchart-complete:disabled:hover {\n","    background-color: var(--disabled-bg-color);\n","    fill: var(--disabled-fill-color);\n","    box-shadow: none;\n","  }\n","\n","  .colab-df-spinner {\n","    border: 2px solid var(--fill-color);\n","    border-color: transparent;\n","    border-bottom-color: var(--fill-color);\n","    animation:\n","      spin 1s steps(1) infinite;\n","  }\n","\n","  @keyframes spin {\n","    0% {\n","      border-color: transparent;\n","      border-bottom-color: var(--fill-color);\n","      border-left-color: var(--fill-color);\n","    }\n","    20% {\n","      border-color: transparent;\n","      border-left-color: var(--fill-color);\n","      border-top-color: var(--fill-color);\n","    }\n","    30% {\n","      border-color: transparent;\n","      border-left-color: var(--fill-color);\n","      border-top-color: var(--fill-color);\n","      border-right-color: var(--fill-color);\n","    }\n","    40% {\n","      border-color: transparent;\n","      border-right-color: var(--fill-color);\n","      border-top-color: var(--fill-color);\n","    }\n","    60% {\n","      border-color: transparent;\n","      border-right-color: var(--fill-color);\n","    }\n","    80% {\n","      border-color: transparent;\n","      border-right-color: var(--fill-color);\n","      border-bottom-color: var(--fill-color);\n","    }\n","    90% {\n","      border-color: transparent;\n","      border-bottom-color: var(--fill-color);\n","    }\n","  }\n","</style>\n","\n","  <script>\n","    async function quickchart(key) {\n","      const quickchartButtonEl =\n","        document.querySelector('#' + key + ' button');\n","      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n","      quickchartButtonEl.classList.add('colab-df-spinner');\n","      try {\n","        const charts = await google.colab.kernel.invokeFunction(\n","            'suggestCharts', [key], {});\n","      } catch (error) {\n","        console.error('Error during call to suggestCharts:', error);\n","      }\n","      quickchartButtonEl.classList.remove('colab-df-spinner');\n","      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n","    }\n","    (() => {\n","      let quickchartButtonEl =\n","        document.querySelector('#df-1c9ff2b7-5185-44b3-bf0a-fc98b137fbe8 button');\n","      quickchartButtonEl.style.display =\n","        google.colab.kernel.accessAllowed ? 'block' : 'none';\n","    })();\n","  </script>\n","</div>\n","\n","  <div id=\"id_4d1b6e6a-a7f9-4f1d-a3e5-b21a4f5aa5a7\">\n","    <style>\n","      .colab-df-generate {\n","        background-color: #E8F0FE;\n","        border: none;\n","        border-radius: 50%;\n","        cursor: pointer;\n","        display: none;\n","        fill: #1967D2;\n","        height: 32px;\n","        padding: 0 0 0 0;\n","        width: 32px;\n","      }\n","\n","      .colab-df-generate:hover {\n","        background-color: #E2EBFA;\n","        box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","        fill: #174EA6;\n","      }\n","\n","      [theme=dark] .colab-df-generate {\n","        background-color: #3B4455;\n","        fill: #D2E3FC;\n","      }\n","\n","      [theme=dark] .colab-df-generate:hover {\n","        background-color: #434B5C;\n","        box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","        filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","        fill: #FFFFFF;\n","      }\n","    </style>\n","    <button class=\"colab-df-generate\" onclick=\"generateWithVariable('hero_hero')\"\n","            title=\"Generate code using this dataframe.\"\n","            style=\"display:none;\">\n","\n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/>\n","  </svg>\n","    </button>\n","    <script>\n","      (() => {\n","      const buttonEl =\n","        document.querySelector('#id_4d1b6e6a-a7f9-4f1d-a3e5-b21a4f5aa5a7 button.colab-df-generate');\n","      buttonEl.style.display =\n","        google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","      buttonEl.onclick = () => {\n","        google.colab.notebook.generateWithVariable('hero_hero');\n","      }\n","      })();\n","    </script>\n","  </div>\n","\n","    </div>\n","  </div>\n"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"dataframe","variable_name":"hero_hero"}},"metadata":{},"execution_count":9}],"source":["# Create weighted adjacent matrix/list for this network\n","hero_hero=hero_hero_comic.groupby(['hero1','hero2']).size().reset_index(name='counts')\n","hero_hero"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":528},"id":"4NDlz9mpr4a0","executionInfo":{"status":"ok","timestamp":1709308289543,"user_tz":300,"elapsed":1977,"user":{"displayName":"清水幸","userId":"09251711040897455590"}},"outputId":"6b3f7c37-41ba-4b8c-d881-498fa7a6addf"},"outputs":[{"output_type":"execute_result","data":{"text/plain":["                      3-D MAN/CHARLES CHAN  AJAK/TECUMOTZIN [ETE  \\\n","3-D MAN/CHARLES CHAN                   102                     1   \n","AJAK/TECUMOTZIN [ETE                     1                   175   \n","ANGEL/WARREN KENNETH                     1                     1   \n","ANT-MAN II/SCOTT HAR                     1                     1   \n","ANT-MAN/DR. HENRY J.                     2                     0   \n","...                                    ...                   ...   \n","YSSA                                     0                     0   \n","ZAKKA                                    0                     0   \n","ZCANN                                    0                     0   \n","ZEAKLAR                                  0                     0   \n","ZZZAX                                    0                     0   \n","\n","                      ANGEL/WARREN KENNETH  ANT-MAN II/SCOTT HAR  \\\n","3-D MAN/CHARLES CHAN                     1                     1   \n","AJAK/TECUMOTZIN [ETE                     1                     1   \n","ANGEL/WARREN KENNETH                  1083                     3   \n","ANT-MAN II/SCOTT HAR                     3                   383   \n","ANT-MAN/DR. HENRY J.                    25                    14   \n","...                                    ...                   ...   \n","YSSA                                     0                     0   \n","ZAKKA                                    0                     0   \n","ZCANN                                    0                     0   \n","ZEAKLAR                                  0                     0   \n","ZZZAX                                    0                     1   \n","\n","                      ANT-MAN/DR. HENRY J.  ARABIAN KNIGHT/ABDUL  \\\n","3-D MAN/CHARLES CHAN                     2                     1   \n","AJAK/TECUMOTZIN [ETE                     0                     1   \n","ANGEL/WARREN KENNETH                    25                     4   \n","ANT-MAN II/SCOTT HAR                    14                     1   \n","ANT-MAN/DR. HENRY J.                  1063                     0   \n","...                                    ...                   ...   \n","YSSA                                     0                     0   \n","ZAKKA                                    0                     0   \n","ZCANN                                    2                     0   \n","ZEAKLAR                                  0                     0   \n","ZZZAX                                    1                     0   \n","\n","                      BANNER, BETTY ROSS T  BEAST/HENRY &HANK& P  \\\n","3-D MAN/CHARLES CHAN                     2                     1   \n","AJAK/TECUMOTZIN [ETE                     0                     1   \n","ANGEL/WARREN KENNETH                     2                   305   \n","ANT-MAN II/SCOTT HAR                     1                     7   \n","ANT-MAN/DR. HENRY J.                     8                    98   \n","...                                    ...                   ...   \n","YSSA                                     0                     0   \n","ZAKKA                                    0                     0   \n","ZCANN                                    0                     0   \n","ZEAKLAR                                  0                     0   \n","ZZZAX                                    3                     0   \n","\n","                      BLACK BOLT/BLACKANTO  BLACK PANTHER/T'CHAL  ...  \\\n","3-D MAN/CHARLES CHAN                     1                     1  ...   \n","AJAK/TECUMOTZIN [ETE                     1                     1  ...   \n","ANGEL/WARREN KENNETH                     8                    11  ...   \n","ANT-MAN II/SCOTT HAR                     9                     8  ...   \n","ANT-MAN/DR. HENRY J.                     7                    86  ...   \n","...                                    ...                   ...  ...   \n","YSSA                                     0                     0  ...   \n","ZAKKA                                    0                     0  ...   \n","ZCANN                                    0                     1  ...   \n","ZEAKLAR                                  0                     0  ...   \n","ZZZAX                                    0                     0  ...   \n","\n","                      WOLFSBANE 2013  WOO, SONIA  XEMU  YELLOWJACKET II/RITA  \\\n","3-D MAN/CHARLES CHAN               0           0     0                     0   \n","AJAK/TECUMOTZIN [ETE               0           0     0                     0   \n","ANGEL/WARREN KENNETH               0           0     0                     0   \n","ANT-MAN II/SCOTT HAR               0           0     0                     3   \n","ANT-MAN/DR. HENRY J.               0           0     0                     2   \n","...                              ...         ...   ...                   ...   \n","YSSA                               0           0     0                     0   \n","ZAKKA                              0           0     0                     0   \n","ZCANN                              0           0     0                     0   \n","ZEAKLAR                            0           0     0                     0   \n","ZZZAX                              0           0     0                     0   \n","\n","                      YOUNG, KIM SUNG  YSSA  ZAKKA  ZCANN  ZEAKLAR  ZZZAX  \n","3-D MAN/CHARLES CHAN                0     0      0      0        0      0  \n","AJAK/TECUMOTZIN [ETE                0     0      0      0        0      0  \n","ANGEL/WARREN KENNETH                0     0      0      0        0      0  \n","ANT-MAN II/SCOTT HAR                0     0      0      0        0      1  \n","ANT-MAN/DR. HENRY J.                0     0      0      2        0      1  \n","...                               ...   ...    ...    ...      ...    ...  \n","YSSA                                0    12      0      0        0      0  \n","ZAKKA                               0     0     11      0        0      0  \n","ZCANN                               0     0      0     72        0      0  \n","ZEAKLAR                             0     0      0      0        2      0  \n","ZZZAX                               0     0      0      0        0     26  \n","\n","[6267 rows x 6267 columns]"],"text/html":["\n","  <div id=\"df-47725225-ed3b-4f6e-8a3e-c95927c29614\" class=\"colab-df-container\">\n","    <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>3-D MAN/CHARLES CHAN</th>\n","      <th>AJAK/TECUMOTZIN [ETE</th>\n","      <th>ANGEL/WARREN KENNETH</th>\n","      <th>ANT-MAN II/SCOTT HAR</th>\n","      <th>ANT-MAN/DR. HENRY J.</th>\n","      <th>ARABIAN KNIGHT/ABDUL</th>\n","      <th>BANNER, BETTY ROSS T</th>\n","      <th>BEAST/HENRY &amp;HANK&amp; P</th>\n","      <th>BLACK BOLT/BLACKANTO</th>\n","      <th>BLACK PANTHER/T'CHAL</th>\n","      <th>...</th>\n","      <th>WOLFSBANE 2013</th>\n","      <th>WOO, SONIA</th>\n","      <th>XEMU</th>\n","      <th>YELLOWJACKET II/RITA</th>\n","      <th>YOUNG, KIM SUNG</th>\n","      <th>YSSA</th>\n","      <th>ZAKKA</th>\n","      <th>ZCANN</th>\n","      <th>ZEAKLAR</th>\n","      <th>ZZZAX</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>3-D MAN/CHARLES CHAN</th>\n","      <td>102</td>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>2</td>\n","      <td>1</td>\n","      <td>2</td>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>...</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","    </tr>\n","    <tr>\n","      <th>AJAK/TECUMOTZIN [ETE</th>\n","      <td>1</td>\n","      <td>175</td>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>0</td>\n","      <td>1</td>\n","      <td>0</td>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>...</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","    </tr>\n","    <tr>\n","      <th>ANGEL/WARREN KENNETH</th>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>1083</td>\n","      <td>3</td>\n","      <td>25</td>\n","      <td>4</td>\n","      <td>2</td>\n","      <td>305</td>\n","      <td>8</td>\n","      <td>11</td>\n","      <td>...</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","    </tr>\n","    <tr>\n","      <th>ANT-MAN II/SCOTT HAR</th>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>3</td>\n","      <td>383</td>\n","      <td>14</td>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>7</td>\n","      <td>9</td>\n","      <td>8</td>\n","      <td>...</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>3</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>1</td>\n","    </tr>\n","    <tr>\n","      <th>ANT-MAN/DR. HENRY J.</th>\n","      <td>2</td>\n","      <td>0</td>\n","      <td>25</td>\n","      <td>14</td>\n","      <td>1063</td>\n","      <td>0</td>\n","      <td>8</td>\n","      <td>98</td>\n","      <td>7</td>\n","      <td>86</td>\n","      <td>...</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>2</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>2</td>\n","      <td>0</td>\n","      <td>1</td>\n","    </tr>\n","    <tr>\n","      <th>...</th>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","      <td>...</td>\n","    </tr>\n","    <tr>\n","      <th>YSSA</th>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>...</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>12</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","    </tr>\n","    <tr>\n","      <th>ZAKKA</th>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>...</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>11</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","    </tr>\n","    <tr>\n","      <th>ZCANN</th>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>2</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>1</td>\n","      <td>...</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>72</td>\n","      <td>0</td>\n","      <td>0</td>\n","    </tr>\n","    <tr>\n","      <th>ZEAKLAR</th>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>...</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>2</td>\n","      <td>0</td>\n","    </tr>\n","    <tr>\n","      <th>ZZZAX</th>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>1</td>\n","      <td>1</td>\n","      <td>0</td>\n","      <td>3</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>...</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>0</td>\n","      <td>26</td>\n","    </tr>\n","  </tbody>\n","</table>\n","<p>6267 rows × 6267 columns</p>\n","</div>\n","    <div class=\"colab-df-buttons\">\n","\n","  <div class=\"colab-df-container\">\n","    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-47725225-ed3b-4f6e-8a3e-c95927c29614')\"\n","            title=\"Convert this dataframe to an interactive table.\"\n","            style=\"display:none;\">\n","\n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n","    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n","  </svg>\n","    </button>\n","\n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    .colab-df-buttons div {\n","      margin-bottom: 4px;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","    <script>\n","      const buttonEl =\n","        document.querySelector('#df-47725225-ed3b-4f6e-8a3e-c95927c29614 button.colab-df-convert');\n","      buttonEl.style.display =\n","        google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","      async function convertToInteractive(key) {\n","        const element = document.querySelector('#df-47725225-ed3b-4f6e-8a3e-c95927c29614');\n","        const dataTable =\n","          await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                    [key], {});\n","        if (!dataTable) return;\n","\n","        const docLinkHtml = 'Like what you see? Visit the ' +\n","          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","          + ' to learn more about interactive tables.';\n","        element.innerHTML = '';\n","        dataTable['output_type'] = 'display_data';\n","        await google.colab.output.renderOutput(dataTable, element);\n","        const docLink = document.createElement('div');\n","        docLink.innerHTML = docLinkHtml;\n","        element.appendChild(docLink);\n","      }\n","    </script>\n","  </div>\n","\n","\n","<div id=\"df-f96e80c6-b817-4a70-9d9f-055c57b702dc\">\n","  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-f96e80c6-b817-4a70-9d9f-055c57b702dc')\"\n","            title=\"Suggest charts\"\n","            style=\"display:none;\">\n","\n","<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","     width=\"24px\">\n","    <g>\n","        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n","    </g>\n","</svg>\n","  </button>\n","\n","<style>\n","  .colab-df-quickchart {\n","      --bg-color: #E8F0FE;\n","      --fill-color: #1967D2;\n","      --hover-bg-color: #E2EBFA;\n","      --hover-fill-color: #174EA6;\n","      --disabled-fill-color: #AAA;\n","      --disabled-bg-color: #DDD;\n","  }\n","\n","  [theme=dark] .colab-df-quickchart {\n","      --bg-color: #3B4455;\n","      --fill-color: #D2E3FC;\n","      --hover-bg-color: #434B5C;\n","      --hover-fill-color: #FFFFFF;\n","      --disabled-bg-color: #3B4455;\n","      --disabled-fill-color: #666;\n","  }\n","\n","  .colab-df-quickchart {\n","    background-color: var(--bg-color);\n","    border: none;\n","    border-radius: 50%;\n","    cursor: pointer;\n","    display: none;\n","    fill: var(--fill-color);\n","    height: 32px;\n","    padding: 0;\n","    width: 32px;\n","  }\n","\n","  .colab-df-quickchart:hover {\n","    background-color: var(--hover-bg-color);\n","    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n","    fill: var(--button-hover-fill-color);\n","  }\n","\n","  .colab-df-quickchart-complete:disabled,\n","  .colab-df-quickchart-complete:disabled:hover {\n","    background-color: var(--disabled-bg-color);\n","    fill: var(--disabled-fill-color);\n","    box-shadow: none;\n","  }\n","\n","  .colab-df-spinner {\n","    border: 2px solid var(--fill-color);\n","    border-color: transparent;\n","    border-bottom-color: var(--fill-color);\n","    animation:\n","      spin 1s steps(1) infinite;\n","  }\n","\n","  @keyframes spin {\n","    0% {\n","      border-color: transparent;\n","      border-bottom-color: var(--fill-color);\n","      border-left-color: var(--fill-color);\n","    }\n","    20% {\n","      border-color: transparent;\n","      border-left-color: var(--fill-color);\n","      border-top-color: var(--fill-color);\n","    }\n","    30% {\n","      border-color: transparent;\n","      border-left-color: var(--fill-color);\n","      border-top-color: var(--fill-color);\n","      border-right-color: var(--fill-color);\n","    }\n","    40% {\n","      border-color: transparent;\n","      border-right-color: var(--fill-color);\n","      border-top-color: var(--fill-color);\n","    }\n","    60% {\n","      border-color: transparent;\n","      border-right-color: var(--fill-color);\n","    }\n","    80% {\n","      border-color: transparent;\n","      border-right-color: var(--fill-color);\n","      border-bottom-color: var(--fill-color);\n","    }\n","    90% {\n","      border-color: transparent;\n","      border-bottom-color: var(--fill-color);\n","    }\n","  }\n","</style>\n","\n","  <script>\n","    async function quickchart(key) {\n","      const quickchartButtonEl =\n","        document.querySelector('#' + key + ' button');\n","      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n","      quickchartButtonEl.classList.add('colab-df-spinner');\n","      try {\n","        const charts = await google.colab.kernel.invokeFunction(\n","            'suggestCharts', [key], {});\n","      } catch (error) {\n","        console.error('Error during call to suggestCharts:', error);\n","      }\n","      quickchartButtonEl.classList.remove('colab-df-spinner');\n","      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n","    }\n","    (() => {\n","      let quickchartButtonEl =\n","        document.querySelector('#df-f96e80c6-b817-4a70-9d9f-055c57b702dc button');\n","      quickchartButtonEl.style.display =\n","        google.colab.kernel.accessAllowed ? 'block' : 'none';\n","    })();\n","  </script>\n","</div>\n","\n","  <div id=\"id_32aacf61-0827-4e4a-b1f4-2e4842ecdd8f\">\n","    <style>\n","      .colab-df-generate {\n","        background-color: #E8F0FE;\n","        border: none;\n","        border-radius: 50%;\n","        cursor: pointer;\n","        display: none;\n","        fill: #1967D2;\n","        height: 32px;\n","        padding: 0 0 0 0;\n","        width: 32px;\n","      }\n","\n","      .colab-df-generate:hover {\n","        background-color: #E2EBFA;\n","        box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","        fill: #174EA6;\n","      }\n","\n","      [theme=dark] .colab-df-generate {\n","        background-color: #3B4455;\n","        fill: #D2E3FC;\n","      }\n","\n","      [theme=dark] .colab-df-generate:hover {\n","        background-color: #434B5C;\n","        box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","        filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","        fill: #FFFFFF;\n","      }\n","    </style>\n","    <button class=\"colab-df-generate\" onclick=\"generateWithVariable('Adj')\"\n","            title=\"Generate code using this dataframe.\"\n","            style=\"display:none;\">\n","\n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/>\n","  </svg>\n","    </button>\n","    <script>\n","      (() => {\n","      const buttonEl =\n","        document.querySelector('#id_32aacf61-0827-4e4a-b1f4-2e4842ecdd8f button.colab-df-generate');\n","      buttonEl.style.display =\n","        google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","      buttonEl.onclick = () => {\n","        google.colab.notebook.generateWithVariable('Adj');\n","      }\n","      })();\n","    </script>\n","  </div>\n","\n","    </div>\n","  </div>\n"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"dataframe","variable_name":"Adj"}},"metadata":{},"execution_count":10}],"source":["# Create Weighted Adjcent Matrix. weight to be the times the hero pair shows together; values on diagnal to be the degree of each node\n","G=nx.from_pandas_edgelist(hero_hero,'hero1','hero2',edge_attr='counts')\n","G=nx.Graph(G)\n","Adj=nx.adjacency_matrix(G,weight='counts').todense()\n","deg=[x[1] for x in list(G.degree)]\n","for i in range(len(Adj)):\n","    Adj[i,i]=deg[i]\n","hero=list(G.nodes)\n","Adj=pd.DataFrame(Adj,columns=hero,index=hero)\n","Adj"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Ww_M_4Isr4a0"},"outputs":[],"source":["# save the tables\n","hero_hero_comic.to_csv('hero_hero_comic.csv',index=False)\n","hero_hero.to_csv('adjacency_list.csv',index=False)\n","Adj.to_csv('adjacency_matrix.csv')\n","Adj.iloc[:50,:50].to_csv('adjacency_matrix_preview.csv')"]}],"metadata":{"kernelspec":{"display_name":"Python 3.11.4 64-bit","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.4"},"orig_nbformat":4,"vscode":{"interpreter":{"hash":"9c3b746aacb193ef1cc3db259ac9b06b57bc8ebd00118a6d0bcea7cc554049a7"}},"colab":{"provenance":[]}},"nbformat":4,"nbformat_minor":0}