-
파이썬에서 그래프를 표현하는 방법
라이브러리는 사용하지 않음
방법
- 인접행룔
- 인접리스트
- 인정다중리스트
- 결합행렬
- 딕셔너리
아래는 대표적으로 그래프를 표현하는 방법(인접행렬, 인접리스트, 결합행렬)
아래에 의하면 인접리스트가 가장 선호하는 방법임
Graph (abstract data type) - Wikipedia
From Wikipedia, the free encyclopedia Jump to navigation Jump to search In computer science, a graph is an abstract data type that is meant to implement the undirected graph and directed graph concepts from the field of graph theory within mathematics. A g
en.wikipedia.org
아래는 인접행렬과 인접리스트 인접다중리스트를 소개하는 글로 인접다중리스트는 리스트를 공유하는 형태이다.
6-2. 그래프의 표현(인접 행렬, 인접 리스트, 인접 다중 리스트)
1. 그래프의 표현 그래프를 표현하는 방법은 여러가지가 있지만 그 중 대표적인 방법이 인접행렬(adjacency matrix), 인접 리스트(adjacency list), 인접 다중 리스트(adjacency multi list)이다. 이때 어떤 표현
kingpodo.tistory.com
아래는 파이썬 공식 문서와 외부문서로 딕셔너리를 이용해 생성함.
Python Patterns - Implementing Graphs
The official home of the Python Programming Language
www.python.org
Generate a graph using Dictionary in Python - GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
www.geeksforgeeks.org
아래는 numpy와dictionary를 비교하는 글임.
특정 key를 필요로한다면 dict가 맞음
Dictionary or Numpy Array?
First, can someone please show the proper code for creating a 5 row 2 column numpy array with type python object? I see a lot of info online but none of it seems to quite show how to do that in one example. Second, If I want to have a string for a k...
python-forum.io
아래 글은 선택하는 순서이다.
When to use pandas series, numpy ndarrays or simply python dictionaries?
I am new to learning Python, and some of its libraries (numpy, pandas). I have found a lot of documentation on how numpy ndarrays, pandas series and python dictionaries work. But owing to my
stackoverflow.com
윗 글에 의하면 딕셔너리보다는 넘파이고 (고차원이며 행렬의 연결 값에 따라 수학적 계산_평균같은_을 할 것이기때문에)
시리즈까지는 가지 않아도됨(merge or export 필요없음)
그.러.나.
로그 순서를 살펴봐야하므로 인접리스트를 써야하는게 맞다. 단순 행렬을 이용하면 흐름을 관찰할 순 없음.
인접리스트의 단점이 i부터 j의 연결도를 알려면 그 연결을 쭉 가야한다는 것인데 이를 역으로 생각하면 i부터 j까지의 흐름을 알 수 있다는 것 아닌가?만일 노드 i와 노드 j의 연결 여부를 알고 싶을 경우에는 어떻게 해야 할까?
adj[i] 의 리스트를 순회하며 j 원소가 존재하는지 확인해야 한다. 이러한 경우 O(V)의 시간 복잡도를 갖게 된다. 인접 행렬은 adj[i][j]가 1인지 0인지만 확인하면 i와 v 노드의 연결 여부를 O(1) 시간복잡도를 통해 확인이 가능했었다.
[Python] 인접 행렬과 인접 리스트
인접 행렬 & 인접 리스트 그래프에 대한 이해가 부족하다고 느껴 다시 공부를 진행하고 있다, 본 문서에서는 그래프를 코드로 구현하는 방법에 대하여 기재한다 알고리즘 문제를 접하다보면 Grap
duwjdtn11.tistory.com
이해를 잘못했다. 흐름은 알 수 없다 단지 연결의 유무만 알 수 있음..! 그냥 인접 리스트를 이용해서 흐름을 알아내는게 나을 것 같음 그게 더 편하고
아래는 구현 방법
Representing a Graph
Representing a Graph In this section we will look at two common abstract representations of graphs: the adjacency matrix and the unfortunately named adjacency “list”. The adjacency list is really a mapping, so in this section we also consider two possi
bradfieldcs.com
그리고 위에 파이썬 문서에 path찾는 코드도 구현되어있다.
위지원데이터 엔지니어로 근무 중에 있으며 데이터와 관련된 일을 모두 좋아합니다!. 특히 ETL 부분에 관심이 가장 크며 데이터를 빛이나게 가공하는 일을 좋아한답니다 ✨
'2020년 > Development' 카테고리의 다른 글
Data munging (0) 2020.12.28 graph2vec를 사용해보자 (3) 2020.12.18 딥러닝 공부 #3 (0) 2020.12.13 캐글을 써보자 (0) 2020.12.08 딥러닝 공부 #2 (0) 2020.12.07