Python package for the CItation-Donor-REcipient (CIDRE) algorithm.
CIDRE is an algorithm to find anomalous groups in directed and weighted networks. An anomalous group consists of donor and recipient nodes, connected by edges with excessive edge weights (i.e., excessive edges). A donor is a node providing excessive edges to other member nodes. A recipient is a node having excessive edges from other member nodes.
If you use this package, please cite:
@misc{kojaku2021cartel,
title={Detecting citation cartels in journal networks},
author={Sadamori Kojaku and Giacomo Livan and Naoki Masuda},
year={2021},
eprint={2009.09097},
archivePrefix={arXiv},
primaryClass={physics.soc-ph}
}
Requirements
- Python 3.7 or later
Install
pip install cidre
Examples
A minimal example
import cidre
alg = cidre.Cidre(group_membership)
groups = alg.detect(A, threshold = 0.15)
group_membership(Optional): If the network has communities, and the communities are not anomalous, tell the communities to CIDRE with this argument.group_membershipshould be numpy.array or list with element,group_membership[i], indicating the group to which node i belongs. Otherwise, setgroup_membership=None.A: Adjacency matrix of the input network (can be weighted or directed). Should be either an nx.Graph or scipy.sparse_csr_matrix. In case of scipy.sparse_csr_matrix format, A[i,j] indicates the weight of the edge from node i to j.threshold: Threshold for the donor and recipient nodes. A larger threshold will yield tighter and smaller groups.groups: List ofGroupinstances. See Group class section.
Group class
Group is a dedicated class for groups of donor and recipient nodes.
The donor and recipient nodes of a group, denoted by group, can be obtained by
group.donors # {node_id: donor_score}
group.recipients # {node_id: recipient_score}
group.donorsis a dict object taking keys and values corresponding to the node IDs and the donor scores, respectively.group.recipientsis the analogous dict object for the recipient nodes.
The number of nodes and edges within the group can be obtained by
group.size() # Number of nodes
group.get_within_edges() # Number of edges within this group
Visualization
cidre package provides an API to visualize small groups. Before using this API, set up your canvas by
import matplotlib.pyplot as plt
width, height = 7, 10
fig, ax = plt.subplots((width, height))
Then, pass ax together with group that you want to visualize to DrawGroup class:
import cidre
dc = cidre.DrawGroup()
dc.draw(group, ax = ax)
This will show a plot like this:
- The left and right nodes correspond to the donor and recipients nodes, respectively.
- The color of each edge corresponds to the color of the source node (i.e., the node from which the edge emanates).
- The width of each edge is proportional to the weight of the edge.
- The text next to each node corresponds to the ID of the node, or equivalently the row id of the adjacency matrix
A.
Instead of node IDs, you may want to display the nodes' labels. To do this, prepare a dict object taking IDs and labels as keys and values, respectively, e.g.,
node_labels = {0:"name 1", 1:"name 2"}
Then, pass it to the draw function as node_labels argument, i.e.,
dc.draw(group, node_labels = node_labels, ax = ax)
Metadata
Release files for cidre 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cidre-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for cidre-0.0.1-py3-none-any.whl |
Release files / cidre-0.0.1-py3-none-any.whl
| Download URL | cidre-0.0.1-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50b785d5a84487cbd5ed1cb805e4825e273ae00a4b533d7ae7f6771a6de0e939
|
|
BLAKE2b-256 checksum How to use checksums |
567c41dff60a831cd16ef2e1eca140ee9647b40d3ee85437bdfcde327fcf241f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
|
Security for cidre 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.