This application claims priority to Chinese Patent Application No. 202010938312.2, filed with the China National Intellectual Property Administration (CNIPA) on Sep. 9, 2020, the content of which is incorporated herein by reference in its entirety.
Embodiments of the present disclosure relate to the field of computer technology, particularly to the technology field of big data, and more particularly to a method and apparatus for converting an undirected relationship to a directed relationship, a device and a storage medium.
There are various kinds of relationship data in real life. For example, the co-occurrence relationship between the ones traveling together. Sine two related persons show up concurrently, it seems like involving an undirected relationship. However, when combined with specific scenarios, such as the transmission of messages or the spread of diseases, the person who travels with the source of the message or diseases later is impossible to transmit the message or viruses to the person of who travels with the source of the message or diseases earlier. Therefore, in this particular spread scenario, the use of the graph of undirected relationship cannot help to analyze the spear or transmission.
In order to solve one or more technical problems mentioned above, embodiments of the present disclosure provides a method and apparatus for converting an undirected relationship to a directed relationship, device and storage medium.
In a first aspect, some embodiments of the present disclosure provide a method for converting an undirected relationship to a directed relationship, the method includes: determining a graph of undirected relationships between a plurality of subjects based on time characteristics of co-occurrences among the plurality of subjects; acquiring time characteristic intervals of edges between an individual subject and related subjects thereof from the graph of the undirected relationships, wherein a time characteristic interval of an edge represents that the individual subject and a related subject co-occurred within the time characteristic interval; sorting the time characteristic intervals, and traversing the time characteristic intervals according to a sorted order, to find a target time characteristic interval not overlapping with a traversed time characteristic interval; and obtaining a directed one-way edge of the individual subject, by using a related subject corresponding to the target time characteristic interval as an end vertex of the one-way edge and using the individual subject as a start vertex of the one-way edge.
In a second aspect, some embodiments of the present disclosure provide an apparatus for converting an undirected relationship to a directed relationship, the apparatus includes: a determination module, configured to determine a graph of undirected relationships between a plurality of subjects based on time characteristics of co-occurrences among the plurality of subjects; an acquisition module, configured to acquire time characteristic intervals of edges between an individual subject and related subjects thereof from the graph of the undirected relationships, where a time characteristic interval of an edge represents that the individual subject and a related subject co-occurred within the time characteristic interval; a searching module, configured to sort the time characteristic intervals, and traversing the time characteristic intervals according to a sorted order, to find a target time characteristic interval not overlapping with a traversed time characteristic interval; and a conversion module, configured to obtain a directed one-way edge of the individual subject, by using a related subject corresponding to the target time characteristic interval as an end vertex of the one-way edge and using the individual subject as a start vertex of the one-way edge.
In a third aspect, some embodiments of the present disclosure provide an electronic device, the electronic device includes: at least one processor; and a memory, in communication with the at least one processor; where, the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method according to any one of the implementations described in the first aspect.
In a fourth aspect, some embodiments of the present disclosure provide a non-transitory computer-readable storage medium having stored thereon computer instructions executable for causing the computer to perform the method according to any one of the implementations described in the first aspect.
It should be understood that the content described in this section is not intended to identify the key or important features of embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood by the following description.
Other features, objectives and advantages of the present disclosure will become more apparent upon reading the detailed description to non-limiting embodiments with reference to the accompanying drawings. The accompanying drawings are used to better understand the present solution and do not constitute a limitation to the present disclosure, in which:
Embodiments of present disclosure will be described below in detail with reference to the accompanying drawings. It should be appreciated that the specific embodiments described herein are merely used for explaining the relevant disclosure, rather than limiting the disclosure. In addition, it should be noted that, for the ease of description, only the parts related to the relevant disclosure are shown in the accompanying drawings.
It should also be noted that some embodiments in the present disclosure and some features in the disclosure may be combined with each other on a non-conflict basis. Features of the present disclosure will be described below in detail with reference to the accompanying drawings and in combination with embodiments.
As shown in
The storage device 101 may interact with the server 130 via the network 102. Data of undirected relationships may be provided in the storage device 101 including but not limited to database, user terminal, etc.
The server 103 may be a server that provides various services. For example, the server may analyze the data of undirected relationships acquired from the storage device 101, to generated an processing result (such as converting the data of undirected relationships to data of directed relationships).
It should be noted that the server 103 may be hardware or software. When the server 103 is hardware, it may be implemented as a distributed server cluster composed of a plurality of servers, or as an individual server. When the server 103 is software, it may be implemented as a plurality of software or software modules (for example, for providing distributed services), or as an individual software or software module, which is not specifically limited herein.
It should be noted that the method for converting an undirected relationship to a directed relationship provided in embodiments of the present disclosure may be performed by the server 103. Accordingly, the apparatus for recognizing face-swap may be provided in the server 103.
It should be understood that the number of terminal devices, networks, and servers in
With further reference to
Step 201, determining a graph of undirected relationships between a plurality of subjects based on time characteristics of co-occurrences among the plurality of subjects traveling together.
In an embodiment, the execution body (for example, the server 103 shown in
In some alternative implementations of the present embodiment, the time characteristics of co-occurrences between a plurality of subjects may be determined based on the time of the earliest contact and the time of the most recent contact among the plurality of subjects. For example, if the time of the earliest contact between the subject A and the subject B is on a certain day at 13:00, and the time of the latest contact is on the same day at 15:00. So that, based on the time of the earliest contact and the time of the latest contact between the subject A and the subject B, the time characteristic intervals [1, 3] of the co-occurrence of the subject A and the subject B can be generated using mapping relationship.
Step 202, acquiring time characteristic intervals of edges between an individual subject and related subjects thereof from the graph of the undirected relationships.
In the present embodiment, the execution body may obtain the time characteristic intervals of edges between an individual subject and related subjects thereof from the graph of the undirected relationships. Taking the relationship diagram shown in
Step 203: sorting the time characteristic intervals, and traversing the time characteristic intervals according to a sorted order, to find a target time characteristic interval not overlapping a traversed time characteristic interval.
In an embodiment, the execution body may sort the time characteristic intervals, traverse the time characteristic intervals according to the sorted order, to find the target time characteristic interval not overlapping the traversed time characteristic intervals. Taking the graph of relationships shown in
Step 204, obtaining a directed one-way edge of the individual subject, by using a related subject corresponding to the target time characteristic interval as an end vertex of the one-way edge and using the individual subject as a start vertex of the one-way edge.
In an embodiment, the execution body may use a related subject corresponding to the target time characteristic interval as the end vertex of a one-way edge, and use the individual subject as the start vertex of the one-way edge, to obtain a directed one-way edge of the individual subject. Still taking the graph of relationships shown in
Compared with prior arts, the embodiment of the present disclosure provides a unified method for converting a large amount of undirected relationship data to directed relationship data, thereby saving labor cost. By converting the undirected relationship data having time attributes into directed relationship data, it is possible to more conveniently and accurately trace the infection path of infected persons, thereby reducing the time for tracing the infection source.
Referring further to
Step 605, merging directed one-way edges of a plurality of individual subjects in the graph of the undirected relationships.
In an embodiment, the execution body (for example, the server 103 shown in
Step 606, removing a one-way edge having opposite directions between two individual subjects, to obtain a graph of one-way edges in the graph of the undirected relationships.
In the present embodiment, the execution body can remove the one-way edges having opposite directions between the two subjects to obtain the graph of one-way relationships of the graph of undirected relationships. The one-way edge having opposite directions refers to an edge with two subjects as start vertex and end vertex mutually. For example, as shown in
In some alternative implementations of the present embodiment, if there is no one-way edge between a individual subject and a related subject thereof in the graph of undirected relationships, the edge between the individual subject and the related subject thereof is marked as two-way edge, so that a graph of two-way edges of the graph of undirected relationships is obtained. With the graph of relationships shown in
An embodiment of the present disclosure also provides a method for converting the undirected relationship data into the directed relationship data. That is, determining a graph of directed edges between individual subjects and related subjects thereof in the graph of the undirected relationships, based on SPARK-GraphX by using an aggregate function of GraphX, where the graph of directed edges includes a one-way edge and a two-way edge. A digraph is determined by using the aggregation function of GraphX, and the pseudo code is as follows:
With further reference to
As shown in
In this embodiment, the processing details of the determination module 801, the acquisition module 802, the searching module 803, and the conversion module 804 in the apparatus 800 for converting an undirected relationship to a directed relationship, and the technical effects thereof can be referred to the relevant descriptions of steps 201-204 in the corresponding method embodiments illustrated in
In some alternative implementations of the present embodiment, the apparatus for converting an undirected relationship to a directed relationship further includes: a merging module, configured to merge directed one-way edges of a plurality of individual subjects in the graph of the undirected relationships; and a one-way graph module, configured to remove one-way edges having opposite directions between two individual subjects, to obtain a graph of one-way edges of the graph of the undirected relationships.
In some alternative implementations of the present embodiment, the apparatus further includes: a two-way graph module, configured to: mark an edge between the individual subject and the related subject thereof as a two-way edge, to obtain a graph of two-way edges of the graph of the undirected relationships, in response to there being no one-way edge between an individual subject and a related subject thereof in the graph of the undirected relationships.
In some alternative implementations of the present embodiment, the apparatus is further configured to: determine a graph of directed edges between individual subjects and related subjects thereof in the graph of the undirected relationships, based on SPARK-GraphX by using an aggregate function of GraphX, where the graph of directed edges includes a one-way edge and a two-way edge.
In some alternative implementations of the present embodiment, the apparatus further includes: a relationship determination module, configured to determine the time characteristics of the co-occurrences among the plurality of subjects based on the time of the earliest co-occurrence and the time of the most recent co-occurrence.
As shown in
As shown in
The memory 902 is a non-transitory computer readable storage medium provided by embodiments of the present disclosure. The memory stores instructions executable by at least one processor, so that the at least one processor performs the method for converting an undirected relationship to a directed relationship provided by embodiments of the present disclosure. The non-transitory computer readable storage medium of the present disclosure stores computer instructions for causing a computer to perform the method for converting an undirected relationship to a directed relationship provided by the present disclosure.
The memory 902, as a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as program instructions/modules corresponding to the method for converting an undirected relationship to a directed relationship in embodiments of the present disclosure (for example, the determination module 801, the acquisition module 802, the searching module 803, and the conversion module 804 shown in
The memory 902 may include a storage program area and a storage data area, where the storage program area may store an operating system and at least one function required application program; and the storage data area may store data created by the use of the electronic device according to the method for converting an undirected relationship to a directed relationship, etc. In addition, the memory 902 may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory 902 may optionally include memories remotely provided with respect to the processor 901, and these remote memories may be connected to the electronic device of the method for converting an undirected relationship to a directed relationship through a network. Examples of the above network include but are not limited to the Internet, intranet, local area network, mobile communication network, and combinations thereof.
The electronic device of the method for converting an undirected relationship to a directed relationship may further include: an input apparatus 903 and an output apparatus 904. The processor 901, the memory 902, the input apparatus 903, and the output apparatus 904 may be connected through a bus or in other methods. In
The input apparatus 903 may receive input digital or character information, and generate key signal inputs related to user settings and function control of the electronic device of the method for converting an undirected relationship to a directed relationship, such as touch screen, keypad, mouse, trackpad, touchpad, pointing stick, one or more mouse buttons, trackball, joystick and other input apparatuses. The output apparatus 904 may include a display device, an auxiliary lighting apparatus (for example, LED), a tactile feedback apparatus (for example, a vibration motor), and the like. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device may be a touch screen.
Various embodiments of the systems and technologies described herein may be implemented in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that can be executed and/or interpreted on a programmable system that includes at least one programmable processor. The programmable processor may be a dedicated or general-purpose programmable processor, and may receive data and instructions from a storage system, at least one input apparatus, and at least one output apparatus, and transmit the data and instructions to the storage system, the at least one input apparatus, and the at least one output apparatus.
These computing programs (also referred to as programs, software, software applications, or codes) include machine instructions of the programmable processor and may use high-level processes and/or object-oriented programming languages, and/or assembly/machine languages to implement these computing programs. As used herein, the terms “machine readable medium” and “computer readable medium” refer to any computer program product, device, and/or apparatus (for example, magnetic disk, optical disk, memory, programmable logic apparatus (PLD)) used to provide machine instructions and/or data to the programmable processor, including machine readable medium that receives machine instructions as machine readable signals. The term “machine readable signal” refers to any signal used to provide machine instructions and/or data to the programmable processor.
In order to provide interaction with a user, the systems and technologies described herein may be implemented on a computer, the computer has: a display apparatus for displaying information to the user (for example, CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and a pointing apparatus (for example, mouse or trackball), and the user may use the keyboard and the pointing apparatus to provide input to the computer. Other types of apparatuses may also be used to provide interaction with the user; for example, feedback provided to the user may be any form of sensory feedback (for example, visual feedback, auditory feedback, or tactile feedback); and any form (including acoustic input, voice input, or tactile input) may be used to receive input from the user.
The systems and technologies described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., application server), or a computing system that includes frontend components (for example, a user computer having a graphical user interface or a web browser, through which the user may interact with the implementations of the systems and the technologies described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., communication network). Examples of the communication network include: local area networks (LAN), wide area networks (WAN), the Internet, and blockchain networks.
The computer system may include a client and a server. The client and the server are generally far from each other and usually interact through the communication network. The relationship between the client and the server is generated by computer programs that run on the corresponding computer and have a client-server relationship with each other.
The technical solution of the present disclosure, by first determining a graph of undirected relationships between a plurality of subjects based on time characteristics of co-occurrences among the plurality of subjects; then acquiring time characteristic intervals of edges between an individual subject and related subjects thereof from the graph of the undirected relationships, where a time characteristic interval of an edge represents that the individual subject and a related subject co-occurred within the time characteristic interval; sorting the time characteristic intervals, and traversing the time characteristic intervals according to a sorted order, to find a target time characteristic interval not overlapping with a traversed time characteristic interval; and obtaining a directed one-way edge of the individual subject, by using a related subject corresponding to the target time characteristic interval as an end vertex of the one-way edge and using the individual subject as a start vertex of the one-way edge, so that it is possible to more conveniently and accurately trace the infection path of infected persons, thereby reducing the time for tracing the infection source.
It should be understood that the various forms of processes shown above may be used to reorder, add, or delete steps. For example, the steps described in the present disclosure may be performed in parallel, sequentially, or in different orders. As long as the desired results of the technical solution disclosed in the present disclosure can be achieved, no limitation is made herein.
The above specific embodiments do not constitute limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions may be made according to design requirements and other factors. Any modification, equivalent replacement and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
202010938312.2 | Sep 2020 | CN | national |