{"id":19199067,"url":"https://github.com/leungll/topk-coding","last_synced_at":"2025-09-07T15:34:44.542Z","repository":{"id":105367545,"uuid":"260174935","full_name":"leungll/Topk-Coding","owner":"leungll","description":"A method to enumerate top-k cliques.","archived":false,"fork":false,"pushed_at":"2024-05-12T13:46:35.000Z","size":307,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-04T11:29:52.892Z","etag":null,"topics":["clause","clique","encoding","solver-algorithm","top-k"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leungll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-30T09:57:05.000Z","updated_at":"2024-05-24T07:05:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"725d225f-0783-499f-9c35-2b9c586c7058","html_url":"https://github.com/leungll/Topk-Coding","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leungll%2FTopk-Coding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leungll%2FTopk-Coding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leungll%2FTopk-Coding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leungll%2FTopk-Coding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leungll","download_url":"https://codeload.github.com/leungll/Topk-Coding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240271535,"owners_count":19774859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clause","clique","encoding","solver-algorithm","top-k"],"created_at":"2024-11-09T12:25:30.981Z","updated_at":"2025-02-23T05:15:34.597Z","avatar_url":"https://github.com/leungll.png","language":"Python","readme":"# TopK-Coding\n![GitHub last commit](https://img.shields.io/github/last-commit/leungll/Topk-Coding?color=9cf\u0026style=flat-square)\n![maven](https://img.shields.io/badge/C%2B%2B11-passing-red)\n![maven](https://img.shields.io/badge/python2-passing-yellow)\n![maven](https://img.shields.io/badge/python3-passing-blue)\n![GitHub](https://img.shields.io/github/license/leungll/Topk-Coding?color=orange\u0026style=flat-square)\n\nThis project contains the software used in the paper \"Fast Enumeration of Large k-Plexes\" authored by Alessio Conte, Donatella Firmani, Caterina Mordente, Maurizio Patrignani, and Riccardo Torlone and published at the 23rd SIGKDD Conference on Knowledge Discovery and Data Mining (KDD 2017).\n\n# Environment\n* Linux\n* python2 **( e.g. python2.7 )**：跑 berlowitz 代码\n* python3：跑 `kplexes.py`\n* c++11\n* 枚举kplex部分需要安装 **[snap.py](https://snap.stanford.edu/snappy/)** 库，`snap.py` 库对环境要求很高\n* 实验代码已在 `ubtuntu 18.04` 系统执行通过\n\n# Prepare\n* 关于python2\n\n    - 如果你的 python2 不是 2.7 版本，需要在 `kplexes.py`(代码大概在 108 行，路径：`Topk-Coding/kplexes.py` )的 `call` 函数中修改对应的 `py2` 版本号\n\n        ```\n        call(\"python2.7 %s %s\" % (berexe, argstring), shell=True, stdout=DEVNULL)\n        ```\n* 安装 **[snap.py](https://snap.stanford.edu/snappy/)** 库\n    - 可直接命令行安装：`pip install snap-stanford`\n    - 下载：**https://snap.stanford.edu/snappy/release**\n    - 执行安装 **( e.g. `ubtuntu 18.04 \u0026 py2.7` )**：\n\n        ```\n        tar zxvf snap-stanford-5.0.0-5.0-ubuntu18.04.2-x64-py2.7.tar.gz\n        cd snap-stanford-5.0.0-5.0-ubuntu18.04.2-x64-py2.7\n        sudo python2.X setup.py install\n        ```\n        \n        ![snap.py-on-linux](https://cdn.jsdelivr.net/gh/leungll/MyImgHosting/img/snap.py-on-linux.jpg)\n# Compile \u0026 Run\n\n```\ncd Topk-Coding\nmkdir working_dir\nmkdir splex_ans\nmkdir input_data\nmkdir input_data_c\nmkdir ans\ng++ -std=c++11 Coding.cpp -o Coding\n./Coding XXX.input_file k\n```\n\n- 后台运行\n    ```\n    ./Coding XXX.input_file k \u0026 \n    python3 kplexes.py --k=XXX --m=0 --fileName=XXX.input_file \u003e ans/XXX.txt \u0026\n    ```\n\n- 查看进程：\n    ```\n    ps -ef | grep Coding\n    ps -ef | grep kplexes.py\n    ```\n\n# Common Commands\n* 查看版本当前**操作系统内核**信息：`uname -a`\n* 查看当前**操作系统版本**信息：`cat /proc/version`\n* 查看版本当前**操作系统发行版**信息：`cat /etc/issue`\n* 查看 cpu 信息：`cat /proc/cpuinfo`\n* 查看 python 具体版本：`python --version`\n* 查看 python 具体安装路径：`which python`\n* 查看 pip 具体版本： `pip --version`\n* 查看 pip 具体安装路径：`which pip`\n* tar.gz 解压：`tar zxvf XXX.tar.gz`\n* zip 解压：`unzip XXX.zip`\n* vim 编辑：\n\n    ```\n    vim /usr/bin/yum \n    i \n    ESC \n    :wq / :q!\n    ```\n* 查看系统 python 版本 ：`ll /usr/bin/python*`\n* 备份 python 原版本：`mv /usr/bin/python /usr/bin/python.bak`\n* 建立 python 软链接：`ln -s /usr/local/python27/bin/python2.7 /usr/bin/python`\n* 恢复原来的 python 指向：`cp /usr/bin/python.bak /usr/bin/python`\n* pip 国内镜像源：\n    - 清华：`pip install 包名 -i https://pypi.tuna.tsinghua.edu.cn/simple `\n    - 阿里云：`pip install 包名 -i http://mirrors.aliyun.com/pypi/simple/`\n    - 豆瓣源（ python 指定 pip ）：`python -m pip install 包名  -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com`\n\n# Pay Attention\n* `Coding.cpp` 中的 `ss_python_cmd` 文件后缀名(1115行)要与 `kplexes.py` 中的 `extension` (33行)匹配\n* 执行命令前需要创建 `5` 个文件夹，否则会报错\n\n    - mkdir working_dir\n    - mkdir splex_ans\n    - mkdir input_data\n    - mkdir input_data_c\n    - mkdir ans\n\n# Update kplexes.py\n* 修改命令行参数（ `argparse` \u0026 `parser` ）\n* 注释\n\n    - 169行：`print(\"%s remove %d edges\" % (datetime.today().strftime('%Y-%m-%d %H:%M:%S'), len(cond)))`\n    - 246行：\n    \n        ```\n        print(\"%s started %d threads (batch_size=%d, procnum=%d)\" % (datetime.today().strftime('%Y-%m-%d %H:%M:%S'), i+1, batch_size, procnum), file = sys.stderr)\n        ```\n    - 250行：`print(\"%s ended thread %d\" % (datetime.today().strftime('%Y-%m-%d %H:%M:%S'), i), file = sys.stderr)`\n    - 293行：`print(sorted_files)`\n* `k` 从命令行接收：\n    - 27行：`k_cmd = args.k`\n    - 304行：`for k in [k_cmd]`\n* 注释 `m` 的运算规则，从命令行接收：\n    - 318行：`m  = max(k**2, math.ceil(fatt))`\n    - 401行：`m  = max(k**2, math.ceil(fatt))`\n    - 28行：`m = args.m`\n* 增加文件比较\n    - 29行：`fileNameStr = args.fileName`\n    - 297行：`if filename == fileNameStr`\n* 修改 `print` 规则\n    * 注释 413 行：`print(P, file=sys.stderr)`\n    * 增加代码 414 行：print(P)\n\n# References\n* http://patrignani.dia.uniroma3.it/large-k-plexes\n* https://github.com/ddfir/kplexes-meta\n* https://snap.stanford.edu/snappy\n* https://github.com/joey001/splex-big\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleungll%2Ftopk-coding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleungll%2Ftopk-coding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleungll%2Ftopk-coding/lists"}