
    <i                     r    S r SSKrSSKJrJrJrJr  \R                  " \5      r	0 SSSS4S jr
0 SSS4S	 jrg)
zGPython APIs for STIX 2 Graph-based Semantic Equivalence and Similarity.    N   )WEIGHTS_bucket_per_type_object_pairsobject_similarityF   F   c                 ,    [        XX$XV40 UD6nX:  a  gg)aW  This method returns a true/false value if two graphs are semantically equivalent.
Internally, it calls the graph_similarity function and compares it against the given
threshold value.

Args:
    ds1: A DataStore object instance representing your graph
    ds2: A DataStore object instance representing your graph
    prop_scores: A dictionary that can hold individual property scores,
        weights, contributing score, matching score and sum of weights.
    threshold: A numerical value between 0 and 100 to determine the minimum
        score to result in successfully calling both graphs equivalent. This
        value can be tuned.
    ignore_spec_version: A boolean indicating whether to test object types
        that belong to different spec versions (STIX 2.0 and STIX 2.1 for example).
        If set to True this check will be skipped.
    versioning_checks: A boolean indicating whether to test multiple revisions
        of the same object (when present) to maximize similarity against a
        particular version. If set to True the algorithm will perform this step.
    max_depth: A positive integer indicating the maximum recursion depth the
        algorithm can reach when de-referencing objects and performing the
        object_similarity algorithm.
    weight_dict: A dictionary that can be used to override what checks are done
        to objects in the similarity process.

Returns:
    bool: True if the result of the graph similarity is greater than or equal to
        the threshold value. False otherwise.

Warning:
    Object types need to have property weights defined for the similarity process.
    Otherwise, those objects will not influence the final score. The WEIGHTS
    dictionary under `stix2.equivalence.graph` can give you an idea on how to add
    new entries and pass them via the `weight_dict` argument. Similarly, the values
    or methods can be fine tuned for a particular use case.

Note:
    Default weight_dict:

    .. include:: ../../similarity_weights.rst

Note:
    This implementation follows the Semantic Equivalence Committee Note.
    see `the Committee Note <link here>`__.

TF)graph_similarity)	ds1ds2prop_scores	thresholdignore_spec_versionversioning_checks	max_depthweight_dictsimilarity_results	            Z/home/james-whalen/.local/lib/python3.13/site-packages/stix2/equivalence/graph/__init__.pygraph_equivalencer      s.    d )+(3 %    c                     0 nSn[         R                  " 5       n	U(       a  U	R                  U5        UUU UUS.U	S'   US::  a  [        S5      e[	        [        U R                  / 5      5      [        UR                  / 5      5      U	5      n
[        R                  SU R                  UR                  5        U
 Hf  u  p0 nUS   nUS   n[        XXUX4U40 U	D6nX;  a	  XUUS.X~'   OUX~   S   :  a  XUUS.X~'   X;  a
  XUUS.X'   MQ  UX   S   :  d  M^  XUUS.X'   Mh     [        S	 UR                  5        5       5      n[        U5      nUS:  a  UU-  nUUS
'   UUS'   XrS'   [        R                  SUUU5        U$ )a  This method returns a similarity score for two given graphs.
Each DataStore can contain a connected or disconnected graph and the
final result is weighted over the amount of objects we managed to compare.
This approach builds on top of the object-based similarity process
and each comparison can return a value between 0 and 100.

Args:
    ds1: A DataStore object instance representing your graph
    ds2: A DataStore object instance representing your graph
    prop_scores: A dictionary that can hold individual property scores,
        weights, contributing score, matching score and sum of weights.
    ignore_spec_version: A boolean indicating whether to test object types
        that belong to different spec versions (STIX 2.0 and STIX 2.1 for example).
        If set to True this check will be skipped.
    versioning_checks: A boolean indicating whether to test multiple revisions
        of the same object (when present) to maximize similarity against a
        particular version. If set to True the algorithm will perform this step.
    max_depth: A positive integer indicating the maximum recursion depth the
        algorithm can reach when de-referencing objects and performing the
        object_similarity algorithm.
    weight_dict: A dictionary that can be used to override what checks are done
        to objects in the similarity process.

Returns:
    float: A number between 0.0 and 100.0 as a measurement of similarity.

Warning:
    Object types need to have property weights defined for the similarity process.
    Otherwise, those objects will not influence the final score. The WEIGHTS
    dictionary under `stix2.equivalence.graph` can give you an idea on how to add
    new entries and pass them via the `weight_dict` argument. Similarly, the values
    or methods can be fine tuned for a particular use case.

Note:
    Default weight_dict:

    .. include:: ../../similarity_weights.rst

Note:
    This implementation follows the Semantic Equivalence Committee Note.
    see `the Committee Note <link here>`__.

r   )r   r   r   r   r   	_internalz"'max_depth' must be greater than 0zCStarting graph similarity process between DataStores: '%s' and '%s'id)lhsrhs
prop_scorevaluer   c              3   *   #    U  H	  oS    v   M     g7f)r   N ).0xs     r   	<genexpr>#graph_similarity.<locals>.<genexpr>   s     >-=7-=s   matching_score	len_pairssummaryzBDONE		LEN_PAIRS: %.2f	MATCHING_SCORE: %.2f	 SIMILARITY_SCORE: %.2f)r   copyupdate
ValueErrorr   r   queryloggerdebugr   r   sumvalueslen)r   r   r   r   r   r   r   resultssimilarity_scoreweightspairsobject1object2iprop_score
object1_id
object2_idresultr%   r&   s                      r   r   r   F   s   ^ GllnG{#  3.GK A~=>>2'2'E LLVX[X^X^`c`f`fg!T]
T]
"k
 !
 $*4Wbms"tGg)'22*4Wbms"tG$*4Wbms"tGg)'22*4Wbms"tG' "* >W^^-=>>NGI1})I5$2K !(K$	
LLP	 r   )__doc__loggingobjectr   r   r   r   	getLogger__name__r,   r   r   r    r   r   <module>r@      sN    M   
		8	$ 8x %qlr   